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

x/rimbu/stream/mod.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.0/stream/mod.ts";

Classes

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

The default AsyncReducer.Impl implementation.

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

The default Reducer.Impl implementation.

Variables

Returns an AsyncReducer that remembers the first input value.

Returns an AsyncReducer 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[]>.

An AsyncReducer that outputs true if no input values are received, false otherwise.

Returns an AsyncReducer 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

An AsyncReducer that outputs true if one or more input values are received, false otherwise.

Returns an AsyncReducer 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 an AsyncReducer 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 an AsyncReducer that only produces an output value when having receives exactly one input value, otherwise will return the otherwise value or undefined.

Returns an async transformer that filters elements from the input stream based on the provided predicate function.

Returns an async transformer that produces windows/collections of windowSize size, each window starting skipAmount of elements after the previous, and optionally collected by a custom reducer.

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.

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.

Returns a transformer that filters elements from the input stream based on the provided predicate function.

Returns a transformer that produces windows/collections of windowSize size, each window starting skipAmount of elements after the previous, and optionally collected by a custom reducer.

Functions

Returns an AsyncReducer 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 an AsyncReducer that returns true if the input values contain the given slice sequence amount times. Otherwise, returns false.

Returns an AsyncReducer with the given options:

Returns an AsyncReducer of which the input, state, and output types are the same.

Returns an AsyncReducer of which the state and output types are the same.

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

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

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

Returns an AsyncReducer that uses the given init and next values to fold the input values into result values.

Returns an AsyncReducer from a given Reducer or AsyncReducer instance.

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

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

Returns an AsyncTransformer instance that converts or filters its input values using given collectFun before passing them to the reducer.

Returns an async transformer that applies the given flatMap function to each element of the input stream, and concatenates all the resulting resulting streams into one stream.

Returns an async transformer that applies the given flatMap function to each element of the input stream, and concatenates all the resulting resulting streams into one stream, where each resulting element is tupled with the originating input element.

Returns an AsyncTransformer based on a given synchronous or asynchronous transformer.

Returns an AsyncTransformer that outputs the index of each received element that satisfies the given predicate.

Returns an AsyncTransformer that inserts the given sep stream source elements between each received input element.

Returns an AsyncTransformer that collects the received elements into a collector that will be returned as output every time the input matches the given sepElem value.

Returns an AsyncTransformer that collects the received elements into a collector that will be returned as output every time the input matches the given sepSlice sequence of elements.

Returns an AsyncTransformer that applies the given pred function to each received element, and collects the received elements into a collector that will be returned as output every time the predicate returns true.

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.

Returns a Transformer instance that converts or filters its input values using given collectFun before passing them to the reducer.

Returns a transformer that returns only those elements from the input that are different to previous element according to the optionally given eq function.

Returns a transformer that applies the given flatMap function to each element of the input stream, and concatenates all the resulting resulting streams into one stream.

Returns a transformer that applies the given flatMap function to each element of the input stream, and concatenates all the resulting resulting streams into one stream, where each resulting element is tupled with the originating input element.

Returns a Transformer that outputs the index of each received element that is equal to the given searchValue value, according to the eq equality function.

Returns a Transformer that outputs the index of each received element that satisfies the given predicate.

Returns a Transfoemr that inserts the given sep stream source elements between each received input element.

Returns a Transformer that collects the received elements into a collector that will be returned as output every time the input matches the given sepElem value.

Returns a Transformer that collects the received elements into a collector that will be returned as output every time the input matches the given sepSlice sequence of elements.

Returns a Transformer that applies the given pred function to each received element, and collects the received elements into a collector that will be returned as output every time the predicate returns true.

Interfaces

An asynchronous iterator that extends the default AsyncIterator interface with methods for improved performance.

The AsyncReducer implementation interface defining the required methods.

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

A possibly infinite asynchronous sequence of elements of type T. See the Stream documentation and the AsyncStream API documentation

A non-empty and possibly infinite asynchronous sequence of elements of type T. See the Stream documentation and the AsyncStream API documentation

Represents an object that can produce an asynchronous stream of values.

Represents a non-empty object that can produce an asynchronous stream of values.

An interface that extends the standard Iterable interface to return a FastIterator instead of a normal Iterator.

An iterator that extends the default Iterator interface with methods that give more performance.

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.

A possibly infinite sequence of elements of type T. See the Stream documentation and the Stream API documentation

A non-empty and possibly infinite sequence of elements of type T. See the Stream documentation and the Stream API documentation

An object that can create a Stream of elements of type T.

An object that can create a non-empty Stream of elements of type T.

Type Aliases

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

Convenience type to allow synchronous reducers to be supplied to functions that accept async reducers.

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

Type defining the allowed shape of async reducer combinations.

An AsyncReducer that produces instances of AsyncStreamSource.

Convenience type to allow synchronous transformers to be supplied to functions that accept async transformers.

Convenience type to allow non-empty synchronous transformers to be supplied to functions that accept non-empty async transformers.

An AsyncReducer that produces instances AsyncStreamSource.NonEmpty.

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.

Any object that is Iterable, a Stream, or can produce a Stream.

Any object that is a non-empty Stream, can produce a non-empty Stream, or is a non-empty array.

A Reducer that produces instances of StreamSource.

A Reducer that produces instances of StreamSource.NonEmpty.