* 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)
| 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` |
no test coverage detected