Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/core/mod.ts>Reducer.Base

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
class Reducer.Base
implements [Reducer.Impl]<I, O, S>
import { Reducer } from "https://deno.land/x/rimbu@1.2.0/core/mod.ts";
const { Base } = Reducer;

A base class that can be used to easily create Reducer instances.

Constructors

new
Base(
init: (initHalt: () => void) => S,
next: (
state: S,
elem: I,
index: number,
halt: () => void,
) => S
,
stateToResult: (
state: S,
index: number,
halted: boolean,
) => O
,
)

Methods

chain(...nextReducers: OptLazy<Reducer<I, any>, [any]>[]): Reducer<I, O>
collectInput<I2>(collectFun: CollectFun<I2, I>): Reducer<I2, O>
dropInput(amount: number): Reducer<I, O>
filterInput(pred: (
value: I,
index: number,
halt: () => void,
) => boolean
, options?: { negate?: boolean | undefined; }
): Reducer<never, O>
flatMapInput<I2>(flatMapFun: (value: I2, index: number) => StreamSource<I>): Reducer<I2, O>
mapInput<I2>(mapFun: (value: I2, index: number) => I): Reducer<I2, O>
mapOutput<O2>(mapFun: (value: O) => O2): Reducer<I, O2>
pipe<O2>(...nextReducers: Reducer<O, O2>[]): Reducer<I, O2>
sliceInput(from?, amount?: number): Reducer<I, O>
takeInput(amount: number): Reducer<I, O>
takeOutput(amount: number): Reducer<I, O>
takeOutputUntil(pred: (value: O, index: number) => boolean, options?: { negate?: boolean; }): Reducer<I, O>