react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / js-yaml / node_modules / argparse / node_modules / lodash / collection / reduce.js
80742 viewsvar arrayReduce = require('../internal/arrayReduce'),1baseEach = require('../internal/baseEach'),2createReduce = require('../internal/createReduce');34/**5* Reduces `collection` to a value which is the accumulated result of running6* each element in `collection` through `iteratee`, where each successive7* invocation is supplied the return value of the previous. If `accumulator`8* is not provided the first element of `collection` is used as the initial9* value. The `iteratee` is bound to `thisArg` and invoked with four arguments:10* (accumulator, value, index|key, collection).11*12* Many lodash methods are guarded to work as iteratees for methods like13* `_.reduce`, `_.reduceRight`, and `_.transform`.14*15* The guarded methods are:16* `assign`, `defaults`, `includes`, `merge`, `sortByAll`, and `sortByOrder`17*18* @static19* @memberOf _20* @alias foldl, inject21* @category Collection22* @param {Array|Object|string} collection The collection to iterate over.23* @param {Function} [iteratee=_.identity] The function invoked per iteration.24* @param {*} [accumulator] The initial value.25* @param {*} [thisArg] The `this` binding of `iteratee`.26* @returns {*} Returns the accumulated value.27* @example28*29* _.reduce([1, 2], function(total, n) {30* return total + n;31* });32* // => 333*34* _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) {35* result[key] = n * 3;36* return result;37* }, {});38* // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed)39*/40var reduce = createReduce(arrayReduce, baseEach);4142module.exports = reduce;434445