* A specialized version of `_.reduce` for arrays without support for * iteratee shorthands. * * @private * @param {Array} [array] The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. * @param {boolean}
(array, iteratee, accumulator, initAccum)
| 27883 | * @returns {*} Returns the accumulated value. |
| 27884 | */ |
| 27885 | function arrayReduce(array, iteratee, accumulator, initAccum) { |
| 27886 | var index = -1, |
| 27887 | length = array == null ? 0 : array.length; |
| 27888 | |
| 27889 | if (initAccum && length) { |
| 27890 | accumulator = array[++index]; |
| 27891 | } |
| 27892 | while (++index < length) { |
| 27893 | accumulator = iteratee(accumulator, array[index], index, array); |
| 27894 | } |
| 27895 | return accumulator; |
| 27896 | } |
| 27897 | |
| 27898 | module.exports = arrayReduce; |
| 27899 |