Last change
on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
746 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var baseEach = require('./_baseEach');
|
---|
| 2 |
|
---|
| 3 | /**
|
---|
| 4 | * Aggregates elements of `collection` on `accumulator` with keys transformed
|
---|
| 5 | * by `iteratee` and values set by `setter`.
|
---|
| 6 | *
|
---|
| 7 | * @private
|
---|
| 8 | * @param {Array|Object} collection The collection to iterate over.
|
---|
| 9 | * @param {Function} setter The function to set `accumulator` values.
|
---|
| 10 | * @param {Function} iteratee The iteratee to transform keys.
|
---|
| 11 | * @param {Object} accumulator The initial aggregated object.
|
---|
| 12 | * @returns {Function} Returns `accumulator`.
|
---|
| 13 | */
|
---|
| 14 | function baseAggregator(collection, setter, iteratee, accumulator) {
|
---|
| 15 | baseEach(collection, function(value, key, collection) {
|
---|
| 16 | setter(accumulator, value, iteratee(value), collection);
|
---|
| 17 | });
|
---|
| 18 | return accumulator;
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | module.exports = baseAggregator;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.