mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Rename initFromArray and initFromCollection vars to initAccum.
This commit is contained in:
28
lodash.js
28
lodash.js
@@ -603,14 +603,14 @@
|
|||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @param {*} [accumulator] The initial value.
|
* @param {*} [accumulator] The initial value.
|
||||||
* @param {boolean} [initFromArray] Specify using the first element of `array` as the initial value.
|
* @param {boolean} [initAccum] Specify using the first element of `array` as the initial value.
|
||||||
* @returns {*} Returns the accumulated value.
|
* @returns {*} Returns the accumulated value.
|
||||||
*/
|
*/
|
||||||
function arrayReduce(array, iteratee, accumulator, initFromArray) {
|
function arrayReduce(array, iteratee, accumulator, initAccum) {
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = array.length;
|
length = array.length;
|
||||||
|
|
||||||
if (initFromArray && length) {
|
if (initAccum && length) {
|
||||||
accumulator = array[++index];
|
accumulator = array[++index];
|
||||||
}
|
}
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
@@ -627,12 +627,12 @@
|
|||||||
* @param {Array} array The array to iterate over.
|
* @param {Array} array The array to iterate over.
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @param {*} [accumulator] The initial value.
|
* @param {*} [accumulator] The initial value.
|
||||||
* @param {boolean} [initFromArray] Specify using the last element of `array` as the initial value.
|
* @param {boolean} [initAccum] Specify using the last element of `array` as the initial value.
|
||||||
* @returns {*} Returns the accumulated value.
|
* @returns {*} Returns the accumulated value.
|
||||||
*/
|
*/
|
||||||
function arrayReduceRight(array, iteratee, accumulator, initFromArray) {
|
function arrayReduceRight(array, iteratee, accumulator, initAccum) {
|
||||||
var length = array.length;
|
var length = array.length;
|
||||||
if (initFromArray && length) {
|
if (initAccum && length) {
|
||||||
accumulator = array[--length];
|
accumulator = array[--length];
|
||||||
}
|
}
|
||||||
while (length--) {
|
while (length--) {
|
||||||
@@ -768,14 +768,14 @@
|
|||||||
* @param {Array|Object} collection The collection to iterate over.
|
* @param {Array|Object} collection The collection to iterate over.
|
||||||
* @param {Function} iteratee The function invoked per iteration.
|
* @param {Function} iteratee The function invoked per iteration.
|
||||||
* @param {*} accumulator The initial value.
|
* @param {*} accumulator The initial value.
|
||||||
* @param {boolean} initFromCollection Specify using the first or last element of `collection` as the initial value.
|
* @param {boolean} initAccum Specify using the first or last element of `collection` as the initial value.
|
||||||
* @param {Function} eachFunc The function to iterate over `collection`.
|
* @param {Function} eachFunc The function to iterate over `collection`.
|
||||||
* @returns {*} Returns the accumulated value.
|
* @returns {*} Returns the accumulated value.
|
||||||
*/
|
*/
|
||||||
function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) {
|
function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
|
||||||
eachFunc(collection, function(value, index, collection) {
|
eachFunc(collection, function(value, index, collection) {
|
||||||
accumulator = initFromCollection
|
accumulator = initAccum
|
||||||
? (initFromCollection = false, value)
|
? (initAccum = false, value)
|
||||||
: iteratee(accumulator, value, index, collection);
|
: iteratee(accumulator, value, index, collection);
|
||||||
});
|
});
|
||||||
return accumulator;
|
return accumulator;
|
||||||
@@ -7832,9 +7832,9 @@
|
|||||||
*/
|
*/
|
||||||
function reduce(collection, iteratee, accumulator) {
|
function reduce(collection, iteratee, accumulator) {
|
||||||
var func = isArray(collection) ? arrayReduce : baseReduce,
|
var func = isArray(collection) ? arrayReduce : baseReduce,
|
||||||
initFromCollection = arguments.length < 3;
|
initAccum = arguments.length < 3;
|
||||||
|
|
||||||
return func(collection, getIteratee(iteratee, 4), accumulator, initFromCollection, baseEach);
|
return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -7859,9 +7859,9 @@
|
|||||||
*/
|
*/
|
||||||
function reduceRight(collection, iteratee, accumulator) {
|
function reduceRight(collection, iteratee, accumulator) {
|
||||||
var func = isArray(collection) ? arrayReduceRight : baseReduce,
|
var func = isArray(collection) ? arrayReduceRight : baseReduce,
|
||||||
initFromCollection = arguments.length < 3;
|
initAccum = arguments.length < 3;
|
||||||
|
|
||||||
return func(collection, getIteratee(iteratee, 4), accumulator, initFromCollection, baseEachRight);
|
return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user