Skip to content

readableStreamFromAsyncIterable

readableStreamFromAsyncIterable<T>(iterable, signal?): Promise<ReadableStream<T>>

Defined in: packages/synapse-core/src/utils/streams.ts:39

Wrap an AsyncIterable in a ReadableStream. The first chunk is read before returning, so the source’s own errors reject here; cancelling the stream calls the iterator’s return.

Type Parameter
T
Parameter Type Description
iterable AsyncIterable<T> The source to read
signal? AbortSignal Aborts the wait for the first chunk

Promise<ReadableStream<T>>

A stream of the iterable’s chunks