Urara-Blog/node_modules/.pnpm-store/v3/files/b7/a92c49998161d5e103126b7181decedacec8ae18f31f295cfbace84c86def514cd52b37941110c4e9006de7c833b2bb32cf1014c88123d1561a59983df8fc8
2022-08-14 01:14:53 +08:00

24 lines
600 B
Text

/**
* The base implementation of `_.sum` and `_.sumBy` without support for
* iteratee 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 result,
index = -1,
length = array.length;
while (++index < length) {
var current = iteratee(array[index]);
if (current !== undefined) {
result = result === undefined ? current : (result + current);
}
}
return result;
}
module.exports = baseSum;