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

Function createReduce

lib/web/jshint.js:4973–4980  ·  view source on GitHub ↗

* Creates a function for `_.reduce` or `_.reduceRight`. * * @private * @param {Function} arrayFunc The function to iterate over an array. * @param {Function} eachFunc The function to iterate over a collection. * @returns {Function} Returns the new each function.

(arrayFunc, eachFunc)

Source from the content-addressed store, hash-verified

4971 * @returns {Function} Returns the new each function.
4972 */
4973 function createReduce(arrayFunc, eachFunc) {
4974 return function(collection, iteratee, accumulator, thisArg) {
4975 var initFromArray = arguments.length < 3;
4976 return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
4977 ? arrayFunc(collection, iteratee, accumulator, initFromArray)
4978 : baseReduce(collection, getCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc);
4979 };
4980 }
4981
4982 /**
4983 * Creates a function that wraps `func` and invokes it with optional `this`

Callers 1

runInContextFunction · 0.85

Calls 3

baseReduceFunction · 0.85
getCallbackFunction · 0.85
isArrayFunction · 0.70

Tested by

no test coverage detected