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

x/rimbu/stream/async-custom/constructors.ts>AsyncStreamConstructors

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

Methods

of<T>(...values: ArrayNonEmpty<AsyncOptLazy<T>>): AsyncStream.NonEmpty<T>
from<T>(...sources: ArrayNonEmpty<AsyncStreamSource.NonEmpty<T>>): AsyncStream.NonEmpty<T>
from<T>(...sources: ArrayNonEmpty<AsyncStreamSource<T>>): AsyncStream<T>
fromResource<T, R>(
open: () => MaybePromise<R>,
createSource: (resource: R) => AsyncStreamSource.NonEmpty<T>,
close: (resource: R) => MaybePromise<void>,
): AsyncStream.NonEmpty<T>
fromResource<T, R>(
open: () => MaybePromise<R>,
createSource: (resource: R) => MaybePromise<AsyncStreamSource<T>>,
close: (resource: R) => MaybePromise<void>,
): AsyncStream<T>
live<T>(maxSize?: number): [{ close: () => void; submit(value: T): void; }, AsyncStream<T>]

Returns a tuple of a controller and a stream, where the controller can be used to submit values and close the stream, and the stream will emit the submitted values, with a buffer of maximum length thte given maxSize. Each stream client will start buffering from the moment that it is created.

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

Returns an AsyncStream 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]: AsyncStreamSource<I[K]> & unknown[]): <R>(zipFun: (...values: I) => R) => AsyncStream<R>
zip<I extends readonly [unknown, ...unknown[]]>(...sources: [K in keyof I]: AsyncStreamSource.NonEmpty<I[K]> & unknown[]): AsyncStream.NonEmpty<I>

Returns an AsyncStream with tuples containing each successive value from the given sources.

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

Returns an AsyncStream 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]: AsyncStreamSource<I[K]> & unknown[]): <O, R>(fillValue: AsyncOptLazy<O>, zipFun: (...values: [K in keyof I]: I[K] | O) => MaybePromise<R>) => AsyncStream<R>
zipAll<I extends readonly [unknown, ...unknown[]], O>(fillValue: AsyncOptLazy<O>, ...sources: [K in keyof I]: AsyncStreamSource.NonEmpty<I[K]> & unknown[]): AsyncStream.NonEmpty<[K in keyof I]: I[K] | O>

Returns an AsyncStream 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: AsyncOptLazy<O>, ...sources: [K in keyof I]: AsyncStreamSource<I[K]> & unknown[]): AsyncStream<[K in keyof I]: I[K] | O>
flatten<T extends AsyncStreamSource.NonEmpty<S>, S>(source: AsyncStreamSource.NonEmpty<T>): AsyncStream.NonEmpty<S>

Returns an AsyncStream concatenating the given source AsyncStreamSource containing StreamSources.

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

Returns an array containing an AsyncStream for each tuple element resulting from given source AsyncStream.

unzip<T extends readonly unknown[] & { length: L; }, L extends number>(source: AsyncStream<T>, length: L): [K in keyof T]: AsyncStream<T[K]>
empty<T>(): AsyncStream<T>
always<T>(value: AsyncOptLazy<T>): AsyncStream.NonEmpty<T>
unfold<T>(init: T, next: (
current: T,
index: number,
stop: Token,
) => MaybePromise<T | Token>
): AsyncStream.NonEmpty<T>

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