Skip to main content

class Base<I,O,S>

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

Implements: Reducer.Impl<I,O,S>

Type parameters

NameDescription
Ithe input value type
Othe output value type
Sthe internal state type

Properties

init

undocumented

Definition

readonly init: (initHalt: () => void) => S;

Overrides

Impl.init

mapInput

Returns a Reducer instance that converts its input values using given mapFun before passing them to this reducer.

Definition

mapInput: <I2>(mapFun: (value: I2, index: number) => I) => Reducer<I2, O>;

example
Reducer.sum.mapInput(v => v * 2)
// this reducer will double all input values before summing them

Overrides

Impl.mapInput

next

undocumented

Definition

readonly next: (state: S, elem: I, index: number, halt: () => void) => S;

stateToResult

undocumented

Definition

readonly stateToResult: (state: S, index: number, halted: boolean) => O;

Methods

chain

undocumented

Definition

chain<O2 extends O>(nextReducers: StreamSource<OptLazy<Reducer<I, O2>, [O2]>>): Reducer<I, O2>;

Type parameters

NameConstraintsDescription
O2O

Parameters

NameTypeDescription
nextReducersStreamSource<OptLazy<Reducer<I, O2>, [O2]>>

Overrides

Impl.chain

collectInput

undocumented

Definition

collectInput<I2>(collectFun: CollectFun<I2, I>): Reducer<I2, O>;

Type parameters

NameDescription
I2

Parameters

NameTypeDescription
collectFunCollectFun<I2, I>

Overrides

Impl.collectInput

compile

undocumented

Definition

compile(): Reducer.Instance<I, O>;

Overrides

Impl.compile

dropInput

undocumented

Definition

dropInput(amount: number): Reducer<I, O>;

Parameters

NameTypeDescription
amountnumber

Overrides

Impl.dropInput

filterInput

undocumented

Definition

filterInput(pred: (value: I, index: number, halt: () => void) => boolean, options?: {
      negate?: boolean | undefined;
    }): any;

Parameters

NameTypeDescription
pred(value: I, index: number, halt: () => void) => boolean
options{
      negate?: boolean | undefined;
    }

Overrides

Impl.filterInput

flatMapInput

undocumented

Definition

flatMapInput<I2>(flatMapFun: (value: I2, index: number) => StreamSource<I>): Reducer<I2, O>;

Type parameters

NameDescription
I2

Parameters

NameTypeDescription
flatMapFun(value: I2, index: number) => StreamSource<I>

Overrides

Impl.flatMapInput

mapInput

undocumented

Definition

mapInput<I2>(mapFun: (value: I2, index: number) => I): Reducer<I2, O>;

Type parameters

NameDescription
I2

Parameters

NameTypeDescription
mapFun(value: I2, index: number) => I

mapOutput

undocumented

Definition

mapOutput<O2>(mapFun: (value: O, index: number, halted: boolean) => O2): Reducer<I, O2>;

Type parameters

NameDescription
O2

Parameters

NameTypeDescription
mapFun(value: O, index: number, halted: boolean) => O2

Overrides

Impl.mapOutput

next

Returns the next state based on the given input values:

Definition

next(state: S, elem: I, index: number, halt: () => void): S;

Parameters

NameTypeDescription
stateSthe current state
elemIthe current input value
indexnumberthe current input index
halt() => voida function that, when called, ensures no more values are passed to the reducer

Overrides

Impl.next

sliceInput

undocumented

Definition

sliceInput(from?: number, amount?: number): Reducer<I, O>;

Parameters

NameTypeDescription
fromnumber
amountnumber

Overrides

Impl.sliceInput

stateToResult

Returns the output value based on the given state.

Definition

stateToResult(state: S, index: number, halted: boolean): O;

Parameters

NameTypeDescription
stateSthe current state
indexnumberthe value index
haltedbooleana boolean indicating whether the reducer is halted

Overrides

Impl.stateToResult

takeInput

undocumented

Definition

takeInput(amount: number): Reducer<I, O>;

Parameters

NameTypeDescription
amountnumber

Overrides

Impl.takeInput

takeOutput

undocumented

Definition

takeOutput(amount: number): Reducer<I, O>;

Parameters

NameTypeDescription
amountnumber

Overrides

Impl.takeOutput

takeOutputUntil

undocumented

Definition

takeOutputUntil(pred: (value: O, index: number) => boolean, options?: {
      negate?: boolean;
    }): Reducer<I, O>;

Parameters

NameTypeDescription
pred(value: O, index: number) => boolean
options{
      negate?: boolean;
    }

Overrides

Impl.takeOutputUntil