UNPKG

@thi.ng/transducers-async

Version:

Async versions of various highly composable transducers, reducers and iterators

18 lines (17 loc) 370 B
import { isReduced } from "@thi.ng/transducers/reduced"; import { compR } from "./compr.js"; const cat = () => (rfn) => { const r = rfn[2]; return compR(rfn, async (acc, x) => { if (x != null) { for await (let y of x) { acc = await r(acc, y); if (isReduced(acc)) return acc.deref(); } } return acc; }); }; export { cat };