mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Bump to v4.1.0.
This commit is contained in:
21
_createAggregator.js
Normal file
21
_createAggregator.js
Normal file
@@ -0,0 +1,21 @@
|
||||
define(['./_arrayAggregator', './_baseAggregator', './_baseIteratee', './isArray'], function(arrayAggregator, baseAggregator, baseIteratee, isArray) {
|
||||
|
||||
/**
|
||||
* Creates a function like `_.groupBy`.
|
||||
*
|
||||
* @private
|
||||
* @param {Function} setter The function to set accumulator values.
|
||||
* @param {Function} [initializer] The accumulator object initializer.
|
||||
* @returns {Function} Returns the new aggregator function.
|
||||
*/
|
||||
function createAggregator(setter, initializer) {
|
||||
return function(collection, iteratee) {
|
||||
var func = isArray(collection) ? arrayAggregator : baseAggregator,
|
||||
accumulator = initializer ? initializer() : {};
|
||||
|
||||
return func(collection, setter, baseIteratee(iteratee), accumulator);
|
||||
};
|
||||
}
|
||||
|
||||
return createAggregator;
|
||||
});
|
||||
Reference in New Issue
Block a user