source: node_modules/es-toolkit/dist/array/reduceAsync.js

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

Added visualizations

  • Property mode set to 100644
File size: 495 bytes
Line 
1'use strict';
2
3Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
5async function reduceAsync(array, reducer, initialValue) {
6 let startIndex = 0;
7 if (initialValue == null) {
8 initialValue = array[0];
9 startIndex = 1;
10 }
11 let accumulator = initialValue;
12 for (let i = startIndex; i < array.length; i++) {
13 accumulator = await reducer(accumulator, array[i], i, array);
14 }
15 return accumulator;
16}
17
18exports.reduceAsync = reduceAsync;
Note: See TracBrowser for help on using the repository browser.