PageRenderTime 23ms CodeModel.GetById 18ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 1var baseSum = require('./_baseSum'),
 2    identity = require('./identity');
 3
 4/**
 5 * Computes the sum of the values in `array`.
 6 *
 7 * @static
 8 * @memberOf _
 9 * @since 3.4.0
10 * @category Math
11 * @param {Array} array The array to iterate over.
12 * @returns {number} Returns the sum.
13 * @example
14 *
15 * _.sum([4, 2, 8, 6]);
16 * // => 20
17 */
18function sum(array) {
19  return (array && array.length)
20    ? baseSum(array, identity)
21    : 0;
22}
23
24module.exports = sum;