From f79148fa625ea4a7084ccd03ab0b9fbeb867c8ef Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 29 Aug 2015 09:16:48 -0700 Subject: [PATCH] Rename `arraySum` to `baseSum`. --- lodash.js | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/lodash.js b/lodash.js index 05266511a..d357db0ec 100644 --- a/lodash.js +++ b/lodash.js @@ -1450,26 +1450,6 @@ return false; } - /** - * A specialized version of `_.sum` for arrays without support for callback - * shorthands. - * - * @private - * @param {Array} array The array to iterate over. - * @param {Function} iteratee The function invoked per iteration. - * @returns {number} Returns the sum. - */ - function arraySum(array, iteratee) { - var index = -1, - length = array.length, - result = 0; - - while (++index < length) { - result += +iteratee(array[index]) || 0; - } - return result; - } - /** * Assigns `value` to `key` of `object` if the existing value is not equivalent * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) @@ -2652,6 +2632,25 @@ return result; } + /** + * The base implementation of `_.sum` without support for callback shorthands. + * + * @private + * @param {Array} array The array to iterate over. + * @param {Function} iteratee The function invoked per iteration. + * @returns {number} Returns the sum. + */ + function baseSum(array, iteratee) { + var index = -1, + length = array.length, + result = 0; + + while (++index < length) { + result += +iteratee(array[index]) || 0; + } + return result; + } + /** * The base implementation of `_.times` without support for callback shorthands * or max array length checks. @@ -11362,7 +11361,7 @@ * // => 10 */ function sum(array) { - return array ? arraySum(array, identity) : 0; + return array ? baseSum(array, identity) : 0; } /** @@ -11392,7 +11391,7 @@ */ function sumBy(array, iteratee) { return (array && array.length) - ? arraySum(array, getIteratee(iteratee)) + ? baseSum(array, getIteratee(iteratee)) : 0; }