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

x/rimbu/common/reducer.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@0.13.0/common/reducer.ts";
const { Base } = Reducer;

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

Constructors

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

Methods

collectInput<I2>(collectFun: CollectFun<I2, I>): Reducer<I2, O>
dropInput(amount: number): Reducer<I, O>
filterInput(pred: (
value: I,
index: number,
halt: () => void,
) => boolean
): Reducer<I, O>
mapInput<I2>(mapFun: (value: I2, index: number) => I): Reducer<I2, O>
mapOutput<O2>(mapFun: (value: O) => O2): Reducer<I, O2>
sliceInput(from?, amount?: number): Reducer<I, O>
takeInput(amount: number): Reducer<I, O>