|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
719 bytes
|
| Rev | Line | |
|---|
| [a762898] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|---|
| 4 |
|
|---|
| 5 | const iteratee = require('../util/iteratee.js');
|
|---|
| 6 |
|
|---|
| 7 | function sumBy(array, iteratee$1) {
|
|---|
| 8 | if (!array || !array.length) {
|
|---|
| 9 | return 0;
|
|---|
| 10 | }
|
|---|
| 11 | if (iteratee$1 != null) {
|
|---|
| 12 | iteratee$1 = iteratee.iteratee(iteratee$1);
|
|---|
| 13 | }
|
|---|
| 14 | let result = undefined;
|
|---|
| 15 | for (let i = 0; i < array.length; i++) {
|
|---|
| 16 | const current = iteratee$1 ? iteratee$1(array[i]) : array[i];
|
|---|
| 17 | if (current !== undefined) {
|
|---|
| 18 | if (result === undefined) {
|
|---|
| 19 | result = current;
|
|---|
| 20 | }
|
|---|
| 21 | else {
|
|---|
| 22 | result += current;
|
|---|
| 23 | }
|
|---|
| 24 | }
|
|---|
| 25 | }
|
|---|
| 26 | return result;
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | exports.sumBy = sumBy;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.