UNPKG

@thi.ng/rstream

Version:

Reactive streams & subscription primitives for constructing dataflow graphs / pipelines

31 lines 964 B
import type { Reducer, Transducer } from "@thi.ng/transducers"; import type { ISubscribable } from "./api.js"; /** * Returns a promise which subscribes to given input and transforms * incoming values using given transducer `xform` and reducer `rfn`. * * @remarks * Once the input or the reducer is done, the promise will resolve with * the final reduced result (or fail with error). * * @example * ```ts tangle:../export/transduce.ts * import { fromIterable, transduce } from "@thi.ng/rstream"; * import { add, map, range } from "@thi.ng/transducers"; * * transduce( * fromIterable(range(10)), * map((x) => x * 10), * add() * ).then((x) => console.log("result", x)) * * // result 450 * ``` * * @param src - * @param xform - * @param rfn - * @param init - */ export declare const transduce: <A, B, C>(src: ISubscribable<A>, xform: Transducer<A, B>, rfn: Reducer<B, C>, init?: C) => Promise<C>; //# sourceMappingURL=transduce.d.ts.map