Function withStreamAdapter

  • Creates a curried function that takes a ReadableStream as an input and returns an async iterable that generates values from the stream.

    Returns

    A function that takes a ReadableStream as input and returns an AsyncIterable of T.

    Example

    const stream = new ReadableStream({
    start(controller) {
    controller.enqueue('Hello');
    controller.close();
    },
    });
    const streamIterable = withStreamAdapter<string>()(stream);

    (async () => {
    for await (const value of streamIterable) {
    console.log(value); // Logs "Hello"
    }
    })();

    Type Parameters

    • T

      The type of data contained in the ReadableStream.

    Returns ((input: ReadableStream<T>) => AsyncIterable<T>)

      • (input: ReadableStream<T>): AsyncIterable<T>
      • Parameters

        • input: ReadableStream<T>

        Returns AsyncIterable<T>

Generated using TypeDoc