UNPKG

@newdash/newdash

Version:

javascript/typescript utility library

22 lines (21 loc) 643 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * The base implementation of `sum` and `sumBy`. * * @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; } exports.default = baseSum;