mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
491 B
21 lines
491 B
10 years ago
|
/**
|
||
9 years ago
|
* A specialized version of `_.sum` for arrays without support for callback
|
||
|
* shorthands and `this` binding..
|
||
10 years ago
|
*
|
||
|
* @private
|
||
|
* @param {Array} array The array to iterate over.
|
||
9 years ago
|
* @param {Function} iteratee The function invoked per iteration.
|
||
10 years ago
|
* @returns {number} Returns the sum.
|
||
|
*/
|
||
9 years ago
|
function arraySum(array, iteratee) {
|
||
10 years ago
|
var length = array.length,
|
||
|
result = 0;
|
||
|
|
||
|
while (length--) {
|
||
9 years ago
|
result += +iteratee(array[length]) || 0;
|
||
10 years ago
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
module.exports = arraySum;
|