groupBy.js 361 B

123456789101112
  1. define(['./_group', './_has'], function (_group, _has) {
  2. // Groups the object's values by a criterion. Pass either a string attribute
  3. // to group by, or a function that returns the criterion.
  4. var groupBy = _group(function(result, value, key) {
  5. if (_has(result, key)) result[key].push(value); else result[key] = [value];
  6. });
  7. return groupBy;
  8. });