mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 10:17:48 +00:00
Use the indicatorObject instead of a boolean in the internals of _.reduce and _.reduceRight.
Former-commit-id: b83d1ef428941f15a6633c1b16b9373210149318
This commit is contained in:
@@ -613,8 +613,8 @@
|
|||||||
* @param {Function|String} [func=identity|property] The function called per
|
* @param {Function|String} [func=identity|property] The function called per
|
||||||
* iteration or property name to query.
|
* iteration or property name to query.
|
||||||
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
||||||
* @param {Boolean} [accumulating] A flag to indicate creating a callback
|
* @param {Object} [accumulating] Used to indicate that the callback should
|
||||||
* that accepts an `accumulator` argument.
|
* accept an `accumulator` argument.
|
||||||
* @returns {Function} Returns a callback function.
|
* @returns {Function} Returns a callback function.
|
||||||
*/
|
*/
|
||||||
function createCallback(func, thisArg, accumulating) {
|
function createCallback(func, thisArg, accumulating) {
|
||||||
@@ -2415,7 +2415,7 @@
|
|||||||
*/
|
*/
|
||||||
function reduce(collection, callback, accumulator, thisArg) {
|
function reduce(collection, callback, accumulator, thisArg) {
|
||||||
var noaccum = arguments.length < 3;
|
var noaccum = arguments.length < 3;
|
||||||
callback = createCallback(callback, thisArg, true);
|
callback = createCallback(callback, thisArg, indicatorObject);
|
||||||
|
|
||||||
if (isArray(collection)) {
|
if (isArray(collection)) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
@@ -2466,7 +2466,7 @@
|
|||||||
} else if (noCharByIndex && isString(collection)) {
|
} else if (noCharByIndex && isString(collection)) {
|
||||||
iteratee = collection.split('');
|
iteratee = collection.split('');
|
||||||
}
|
}
|
||||||
callback = createCallback(callback, thisArg, true);
|
callback = createCallback(callback, thisArg, indicatorObject);
|
||||||
forEach(collection, function(value, index, collection) {
|
forEach(collection, function(value, index, collection) {
|
||||||
index = props ? props[--length] : --length;
|
index = props ? props[--length] : --length;
|
||||||
accumulator = noaccum
|
accumulator = noaccum
|
||||||
|
|||||||
Reference in New Issue
Block a user