1 var arrayReduceRight = require('./_arrayReduceRight'),
2 baseEachRight = require('./_baseEachRight'),
3 baseIteratee = require('./_baseIteratee'),
4 baseReduce = require('./_baseReduce'),
5 isArray = require('./isArray');
8 * This method is like `_.reduce` except that it iterates over elements of
9 * `collection` from right to left.
14 * @category Collection
15 * @param {Array|Object} collection The collection to iterate over.
16 * @param {Function} [iteratee=_.identity] The function invoked per iteration.
17 * @param {*} [accumulator] The initial value.
18 * @returns {*} Returns the accumulated value.
22 * var array = [[0, 1], [2, 3], [4, 5]];
24 * _.reduceRight(array, function(flattened, other) {
25 * return flattened.concat(other);
27 * // => [4, 5, 2, 3, 0, 1]
29 function reduceRight(collection, iteratee, accumulator) {
30 var func = isArray(collection) ? arrayReduceRight : baseReduce,
31 initAccum = arguments.length < 3;
33 return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
36 module.exports = reduceRight;