Skip to main content
Module

x/rimbu/stream/custom/index.ts>StreamConstructors

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
interface StreamConstructors
Re-export
import { type StreamConstructors } from "https://deno.land/x/rimbu@0.14.0/stream/custom/index.ts";

Methods

empty<T>(): Stream<T>

Returns an empty Stream of given type T.

of<T>(...values: ArrayNonEmpty<T>): Stream.NonEmpty<T>

Returns a non-empty Stream containing the given values

from<T>(...sources: ArrayNonEmpty<StreamSource.NonEmpty<T>>): Stream.NonEmpty<T>

Returns a Stream containing the values in the given sources concatenated

from<T>(...sources: ArrayNonEmpty<StreamSource<T>>): Stream<T>
fromArray<T>(
array: ArrayNonEmpty<T>,
range?: undefined,
reversed?: boolean,
): Stream.NonEmpty<T>

Returns a Stream returning elements from the given array, taking into account the given options.

fromArray<T>(
array: readonly T[],
range?: IndexRange,
reversed?: boolean,
): Stream<T>
fromObjectKeys<K extends string | number | symbol>(obj: Record<K, any>): Stream<K>

Returns a Stream consisting of the object keys from the given obj object.

fromObjectValues<V>(obj: Record<any, V> | readonly V[]): Stream<V>

Returns a Stream consisting of the object values from the given obj object.

fromObject<K extends string | number | symbol, V>(obj: Record<K, V>): Stream<[K, V]>

Returns a Stream consisting of the object entries as tuples from the given obj object.

fromString<S extends string>(
source: StringNonEmpty<S>,
range?: undefined,
reversed?: boolean,
): Stream.NonEmpty<string>

Returns a Stream consisting of the characters from given string source, taking into account the given options.

fromString(
source: string,
range?: IndexRange,
reversed?: boolean,
): Stream<string>
always<T>(value: T): Stream.NonEmpty<T>

Returns a Stream that eternally returns the given value.

applyForEach<T extends readonly unknown[], A extends readonly unknown[]>(
source: StreamSource<Readonly<T>>,
f: (...args: [...T, ...A]) => void,
...args: A,
): void

For a Stream of tuples, supplied each tuple element as an argument to given function f for each element of the Stream, with the optionally given args as extra arguments.

applyMap<T extends readonly unknown[], A extends readonly unknown[], R>(
source: StreamSource.NonEmpty<Readonly<T>>,
mapFun: (...args: [...T, ...A]) => R,
...args: A,
): Stream.NonEmpty<R>

For a Stream of tuples in given source, returns a Stream with the result of supplying each tuple element as an argument to given mapFun function for each element of the Stream, with the optionally given args as extra arguments.

applyMap<T extends readonly unknown[], A extends readonly unknown[], R>(
source: StreamSource<Readonly<T>>,
mapFun: (...args: [...T, ...A]) => R,
...args: A,
): Stream<R>
applyFilter<T extends readonly unknown[], A extends readonly unknown[]>(
source: StreamSource<Readonly<T>>,
pred: (...args: [...T, ...A]) => boolean,
...args: A,
): Stream<T>

For a Stream of tuples in given source, returns a Stream where the result of supplying each tuple element as an argument to given mapFun function for each element of the Stream, with the optionally given args as extra arguments, is true.

range(range: IndexRange, delta?: number): Stream<number>

Returns a Stream of numbers within the given range, increasing or decreasing with optionally given delta.

random(): Stream.NonEmpty<number>

Returns an infinite Stream containing random numbers between 0 and 1.

randomInt(min: number, max: number): Stream.NonEmpty<number>

Returns an infinite Stream containing random integer numbers between given min and max

unfold<T>(init: T, next: (
current: T,
index: number,
stop: Token,
) => T | Token
): Stream.NonEmpty<T>

Returns a possibly infinite Stream starting with given init value, followed by applying given next function to the previous value.

zipWith<I extends readonly [unknown, ...unknown[]]>(...sources: [K in keyof I]: StreamSource.NonEmpty<I[K]> & unknown[]): <R>(zipFun: (...values: I) => R) => Stream.NonEmpty<R>

Returns a Stream with the result of applying given zipFun to each successive value resulting from the given sources.

zipWith<I extends readonly [unknown, ...unknown[]]>(...sources: [K in keyof I]: StreamSource<I[K]> & unknown[]): <R>(zipFun: (...values: I) => R) => Stream<R>
zip<I extends readonly [unknown, ...unknown[]]>(...sources: [K in keyof I]: StreamSource.NonEmpty<I[K]> & unknown[]): Stream.NonEmpty<I>

Returns a Stream with tuples containing each successive value from the given sources.

zip<I extends readonly [unknown, ...unknown[]]>(...sources: [K in keyof I]: StreamSource<I[K]> & unknown[]): Stream<I>
zipAllWith<I extends readonly [unknown, ...unknown[]]>(...sources: [K in keyof I]: StreamSource.NonEmpty<I[K]> & unknown[]): <O, R>(fillValue: OptLazy<O>, zipFun: (...values: [K in keyof I]: I[K] | O) => R) => Stream.NonEmpty<R>

Returns a Stream with the result of applying given zipFun to each successive value resulting from the given sources, adding given fillValue to any Streams that end before all streams have ended.

zipAllWith<I extends readonly [unknown, ...unknown[]]>(...sources: [K in keyof I]: StreamSource<I[K]> & unknown[]): <O, R>(fillValue: OptLazy<O>, zipFun: (...values: [K in keyof I]: I[K] | O) => R) => Stream<R>
zipAll<I extends readonly [unknown, ...unknown[]], O>(fillValue: OptLazy<O>, ...sources: [K in keyof I]: StreamSource.NonEmpty<I[K]> & unknown[]): Stream.NonEmpty<[K in keyof I]: I[K] | O>

Returns a Stream with tuples containing each successive value from the given sources, adding given fillValue to any Streams that end before all streams have ended.

zipAll<I extends readonly [unknown, ...unknown[]], O>(fillValue: OptLazy<O>, ...sources: [K in keyof I]: StreamSource<I[K]> & unknown[]): Stream<[K in keyof I]: I[K] | O>
flatten<T extends StreamSource.NonEmpty<S>, S>(source: StreamSource.NonEmpty<T>): Stream.NonEmpty<S>

Returns a Stream concatenating the given source StreamSource containing StreamSources.

flatten<T extends StreamSource<S>, S>(source: StreamSource<T>): Stream<S>
unzip<T extends readonly unknown[] & { length: L; }, L extends number>(source: Stream.NonEmpty<T>, length: L): [K in keyof T]: Stream.NonEmpty<T[K]>

Returns an array containing a Stream for each tuple element in this stream.

unzip<T extends readonly unknown[] & { length: L; }, L extends number>(source: Stream<T>, length: L): [K in keyof T]: Stream<T[K]>