90de912aa353f386e24ee03d598efdd2597b9785194d7000b8b205b4d8803b8f83a9b23c165c8d3d29e5d43ad698a2ad47aa240631f24ea36655bd6a92a842 787 B

1234567891011121314151617181920212223
  1. import arrayAggregator from './_arrayAggregator.js';
  2. import baseAggregator from './_baseAggregator.js';
  3. import baseIteratee from './_baseIteratee.js';
  4. import isArray from './isArray.js';
  5. /**
  6. * Creates a function like `_.groupBy`.
  7. *
  8. * @private
  9. * @param {Function} setter The function to set accumulator values.
  10. * @param {Function} [initializer] The accumulator object initializer.
  11. * @returns {Function} Returns the new aggregator function.
  12. */
  13. function createAggregator(setter, initializer) {
  14. return function(collection, iteratee) {
  15. var func = isArray(collection) ? arrayAggregator : baseAggregator,
  16. accumulator = initializer ? initializer() : {};
  17. return func(collection, setter, baseIteratee(iteratee, 2), accumulator);
  18. };
  19. }
  20. export default createAggregator;