source: node_modules/es-toolkit/dist/compat/math/sumBy.mjs@ a762898

Last change on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 616 bytes
Line 
1import { iteratee } from '../util/iteratee.mjs';
2
3function sumBy(array, iteratee$1) {
4 if (!array || !array.length) {
5 return 0;
6 }
7 if (iteratee$1 != null) {
8 iteratee$1 = iteratee(iteratee$1);
9 }
10 let result = undefined;
11 for (let i = 0; i < array.length; i++) {
12 const current = iteratee$1 ? iteratee$1(array[i]) : array[i];
13 if (current !== undefined) {
14 if (result === undefined) {
15 result = current;
16 }
17 else {
18 result += current;
19 }
20 }
21 }
22 return result;
23}
24
25export { sumBy };
Note: See TracBrowser for help on using the repository browser.