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

x/rimbu/stream/main/reducer.ts

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
import * as rimbu from "https://deno.land/x/rimbu@1.2.1/stream/main/reducer.ts";

Classes

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

The default Reducer.Impl implementation.

Variables

A Reducer that takes boolean values and outputs true if all input values are true, and false otherwise.

A Reducer that calculates the average of all given numberic input values.

A Reducer that remembers the amount of input items provided.

Returns a Reducer that remembers the first input value.

Returns a Reducer that uses the valueToKey function to calculate a key for each value, and feeds the tuple of the key and the value to the collector reducer. Finally, it returns the output of the collector. If no collector is given, the default collector will return a JS multimap of the type Map<K, V[]>.

A Reducer that outputs true if no input values are received, false otherwise.

Returns a Reducer that remembers the last input value.

Returns a Reducer that remembers the maximum value of the numberic inputs.

Returns a Reducer that remembers the maximum value of the inputs using the given compFun to compare input values

Returns a Reducer that remembers the minimum value of the numberic inputs.

Returns a Reducer that remembers the minimum value of the inputs using the given compFun to compare input values

A Reducer that outputs true if one or more input values are received, false otherwise.

A Reducer that takes boolean values and outputs true if one or more input values are true, and false otherwise.

Returns a Reducer that splits the incoming values into two separate outputs based on the given pred predicate. Values for which the predicate is true are fed into the collectorTrue reducer, and other values are fed into the collectorFalse instance. If no collectors are provided the values are collected into arrays.

Returns a Reducer instance that first applies this reducer, and then applies the given next reducer to each output produced by the previous reducer.

A Reducer that calculates the product of all given numeric input values.

Returns a Reducer that feeds incoming values to all reducers in the provided reducers source, and halts when the first reducer in the array is halted and returns the output of that reducer. Returns the otherwise value if no reducer is yet halted.

Returns a Reducer that only produces an output value when having receives exactly one input value, otherwise will return the otherwise value or undefined.

A Reducer that sums all given numeric input values.

Functions

Returns a Reducer that combines multiple input reducers according to the given "shape" by providing input values to all of them and collecting the outputs in the shape.

Returns a Reducer that always outputs the given value, and does not accept input values.

Returns a Reducer that outputs false as long as the given elem has not been encountered the given amount of times in the input values, true otherwise.

Returns a Reducer that returns true if the input values contain the given slice sequence amount times. Otherwise, returns false.

Returns a Reducer with the given options:

Returns a Reducer of which the input, state, and output types are the same.

Returns a Reducer of which the state and output types are the same.

Returns a Reducer that returns true if the last input values match the given slice values repeated amount times. Otherwise, returns false.

Returns a Reducer that ouputs true when the received elements match the given other stream source according to the eq instance, false otherwise.

Returns a Reducer that ouputs true as long as all input values satisfy the given pred, false otherwise.

Returns a Reducer that uses the given init and next values to fold the input values into result values.

Returns a Reducer that joins the given input values into a string using the given options.

Returns a Reducer that ouputs false as long as no input value satisfies given pred, true otherwise.

Returns a Reducer that returns true if the first input values match the given slice values repeated amount times. Otherwise, returns false.

Returns a Reducer that collects received input values in an array, and returns a copy of that array as an output value when requested.

Returns a Reducer that collects received input tuples into a mutable JS Map, and returns a copy of that map when output is requested.

Returns a Reducer that collects received input tuples into a mutable JS multimap, and returns a copy of that map when output is requested.

Returns a Reducer that collects 2-tuples containing keys and values into a plain JS object, and returns a copy of that object when output is requested.

Returns a Reducer that collects received input values into a mutable JS Set, and returns a copy of that map when output is requested.

Interfaces

The Implementation interface for a Reducer, which also exposes the internal state type.

A reducer instance that manages its own state based on the reducer definition that was used to create this instance.

Type Aliases

A Reducer is a stand-alone calculation that takes input values of type I, and, when requested, produces an output value of type O.

Type defining the result type of a reducer combination for a given shape.

Type defining the allowed shape of reducer combinations.