UNPKG

iterama

Version:

Composable functional (async) iterable helpers

19 lines (15 loc) 385 B
Object.defineProperty(exports, "__esModule", { value: true }); exports.scanAsync = void 0; const scanAsync = (scanFn, initial) => iterable => ({ async *[Symbol.asyncIterator]() { let state = await initial; let i = 0; for await (const value of iterable) { state = await scanFn(state, value, i++); yield state; } } }); exports.scanAsync = scanAsync;