Skip to content

reduce

An async reduce function. Works like the built-in Array.reduce function but handles an async reducer function.

Usage

const result = await reduce(
[1, 2, 3],
async (acc, item, index) => {
return acc + (await computeOnGPU(item));
},
0,
);

Installation

Terminal window
npx atmx add helper reduce