UNPKG

@thi.ng/transducers

Version:

Collection of ~170 lightweight, composable transducers, reducers, generators, iterators for functional data transformations

29 lines 1.01 kB
import type { Reducer, ReductionFn } from "./api.js"; /** * Reducer composition helper, internally used by various transducers * during initialization. Takes existing reducer `rfn` (a 3-tuple) and a * reducing function `fn`. Returns a new reducer tuple. * * @remarks * `rfn[2]` reduces values of type `B` into an accumulator of type `A`. * `fn` accepts values of type `C` and produces interim results of type * `B`, which are then (possibly) passed to the "inner" `rfn[2]` * function. Therefore the resulting reducer takes inputs of `C` and an * accumulator of type `A`. * * It is assumed that `fn` internally calls `rfn[2]` to pass its own * results for further processing by the nested reducer `rfn`. * * @example * ```ts * import { compR } from "@thi.ng/transducers"; * * compR(rfn, fn) * // [rfn[0], rfn[1], fn] * ``` * * @param rfn - * @param fn - */ export declare const compR: <A, B, C>(rfn: Reducer<B, C>, fn: ReductionFn<A, C>) => Reducer<A, C>; //# sourceMappingURL=compr.d.ts.map