* Creates a function that aggregates a collection, creating an object composed * of keys generated from the results of running each element of the collection * through a callback. The given `setter` function sets the keys and values * of the composed object. * * @private
(setter)
| 36482 | * @returns {Function} Returns the new aggregator function. |
| 36483 | */ |
| 36484 | function createAggregator(setter) { |
| 36485 | return function(collection, callback, thisArg) { |
| 36486 | var result = {}; |
| 36487 | callback = lodash.createCallback(callback, thisArg, 3); |
| 36488 | |
| 36489 | var index = -1, |
| 36490 | length = collection ? collection.length : 0; |
| 36491 | |
| 36492 | if (typeof length == 'number') { |
| 36493 | while (++index < length) { |
| 36494 | var value = collection[index]; |
| 36495 | setter(result, value, callback(value, index, collection), collection); |
| 36496 | } |
| 36497 | } else { |
| 36498 | forOwn(collection, function(value, key, collection) { |
| 36499 | setter(result, value, callback(value, key, collection), collection); |
| 36500 | }); |
| 36501 | } |
| 36502 | return result; |
| 36503 | }; |
| 36504 | } |
| 36505 | |
| 36506 | /** |
| 36507 | * Creates a function that, when called, either curries or invokes `func` |
no test coverage detected