MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / createAggregator

Function createAggregator

lib/web/jshint.js:4550–4570  ·  view source on GitHub ↗

* Creates a function that aggregates a collection, creating an accumulator * object composed from the results of running each element in the collection * through an iteratee. * * **Note:** This function is used to create `_.countBy`, `_.groupBy`, `_.indexBy`, * and `_.partit

(setter, initializer)

Source from the content-addressed store, hash-verified

4548 * @returns {Function} Returns the new aggregator function.
4549 */
4550 function createAggregator(setter, initializer) {
4551 return function(collection, iteratee, thisArg) {
4552 var result = initializer ? initializer() : {};
4553 iteratee = getCallback(iteratee, thisArg, 3);
4554
4555 if (isArray(collection)) {
4556 var index = -1,
4557 length = collection.length;
4558
4559 while (++index < length) {
4560 var value = collection[index];
4561 setter(result, value, iteratee(value, index, collection), collection);
4562 }
4563 } else {
4564 baseEach(collection, function(value, key, collection) {
4565 setter(result, value, iteratee(value, key, collection), collection);
4566 });
4567 }
4568 return result;
4569 };
4570 }
4571
4572 /**
4573 * Creates a function that assigns properties of source object(s) to a given

Callers 1

runInContextFunction · 0.85

Calls 2

getCallbackFunction · 0.85
isArrayFunction · 0.70

Tested by

no test coverage detected