groupBy.js 331 B

12345678
  1. import group from './_group.js';
  2. import has from './_has.js';
  3. // Groups the object's values by a criterion. Pass either a string attribute
  4. // to group by, or a function that returns the criterion.
  5. export default group(function(result, value, key) {
  6. if (has(result, key)) result[key].push(value); else result[key] = [value];
  7. });