2 * The base implementation of `_.reduce` and `_.reduceRight`, without support
3 * for iteratee shorthands, which iterates over `collection` using `eachFunc`.
6 * @param {Array|Object} collection The collection to iterate over.
7 * @param {Function} iteratee The function invoked per iteration.
8 * @param {*} accumulator The initial value.
9 * @param {boolean} initAccum Specify using the first or last element of `collection` as the initial value.
10 * @param {Function} eachFunc The function to iterate over `collection`.
11 * @returns {*} Returns the accumulated value.
13 function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
14 eachFunc(collection, function(value, index, collection) {
15 accumulator = initAccum
16 ? (initAccum = false, value)
17 : iteratee(accumulator, value, index, collection);
22 module.exports = baseReduce;