6a355bce82f77c9e07c4b4c98b474bfa9df01a85
[yaffs-website] / node_modules / uncss / node_modules / lodash / internal / arrayReduce.js
1 /**
2  * A specialized version of `_.reduce` for arrays without support for
3  * iteratee shorthands.
4  *
5  * @private
6  * @param {Array} array The array 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 element of `array` as the initial value.
10  * @returns {*} Returns the accumulated value.
11  */
12 function arrayReduce(array, iteratee, accumulator, initAccum) {
13   var index = -1,
14       length = array.length;
15
16   if (initAccum && length) {
17     accumulator = array[++index];
18   }
19   while (++index < length) {
20     accumulator = iteratee(accumulator, array[index], index, array);
21   }
22   return accumulator;
23 }
24
25 module.exports = arrayReduce;