/node_modules/lodash/sum.js
https://bitbucket.org/coleman333/smartsite · JavaScript · 24 lines · 8 code · 2 blank · 14 comment · 1 complexity · 27ba2f5aa1d53e851e20e50e686fe73a MD5 · raw file
- var baseSum = require('./_baseSum'),
- identity = require('./identity');
- /**
- * Computes the sum of the values in `array`.
- *
- * @static
- * @memberOf _
- * @since 3.4.0
- * @category Math
- * @param {Array} array The array to iterate over.
- * @returns {number} Returns the sum.
- * @example
- *
- * _.sum([4, 2, 8, 6]);
- * // => 20
- */
- function sum(array) {
- return (array && array.length)
- ? baseSum(array, identity)
- : 0;
- }
- module.exports = sum;