axax
Version:
A library of async iterator extensions for JavaScript including ```map```, ```reduce```, ```filter```, ```flatMap```, ```pipe``` and [more](https://github.com/jamiemccrindle/axax/blob/master/docs/API.md#functions).
16 lines (15 loc) • 391 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Reduces values
*/
function reduce(reducer, init) {
return async function inner(source) {
let accumulator = await init;
for await (const next of source) {
accumulator = await reducer(accumulator, next);
}
return accumulator;
};
}
exports.reduce = reduce;