Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_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;