Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

_baseAggregator.js 746B

123456789101112131415161718192021
  1. var baseEach = require('./_baseEach');
  2. /**
  3. * Aggregates elements of `collection` on `accumulator` with keys transformed
  4. * by `iteratee` and values set by `setter`.
  5. *
  6. * @private
  7. * @param {Array|Object} collection The collection to iterate over.
  8. * @param {Function} setter The function to set `accumulator` values.
  9. * @param {Function} iteratee The iteratee to transform keys.
  10. * @param {Object} accumulator The initial aggregated object.
  11. * @returns {Function} Returns `accumulator`.
  12. */
  13. function baseAggregator(collection, setter, iteratee, accumulator) {
  14. baseEach(collection, function(value, key, collection) {
  15. setter(accumulator, value, iteratee(value), collection);
  16. });
  17. return accumulator;
  18. }
  19. module.exports = baseAggregator;