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

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

Added visualizations

  • Property mode set to 100644
File size: 395 bytes
Line 
1async function reduceAsync(array, reducer, initialValue) {
2 let startIndex = 0;
3 if (initialValue == null) {
4 initialValue = array[0];
5 startIndex = 1;
6 }
7 let accumulator = initialValue;
8 for (let i = startIndex; i < array.length; i++) {
9 accumulator = await reducer(accumulator, array[i], i, array);
10 }
11 return accumulator;
12}
13
14export { reduceAsync };
Note: See TracBrowser for help on using the repository browser.