modal
    Preparing search index...

    Interface ModalReadStream<R>

    Wrapper around ReadableStream with convenience functions.

    The Stream API is a modern standard for asynchronous data streams across network and process boundaries. It allows you to read data in chunks, pipe and transform it, and handle backpressure.

    This wrapper adds some extra functions like .readText() to read the entire stream as a string, or readBytes() to read binary data.

    Background: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API

    interface ModalReadStream<R = any> {
        locked: boolean;
        "[asyncIterator]"(): ReadableStreamAsyncIterator<R>;
        cancel(reason?: any): Promise<void>;
        getReader(options: { mode: "byob" }): ReadableStreamBYOBReader;
        getReader(): ReadableStreamDefaultReader<R>;
        getReader(
            options?: ReadableStreamGetReaderOptions,
        ): ReadableStreamReader<R>;
        pipeThrough<T>(
            transform: ReadableWritablePair<T, R>,
            options?: StreamPipeOptions,
        ): ReadableStream<T>;
        pipeTo(
            destination: WritableStream<R>,
            options?: StreamPipeOptions,
        ): Promise<void>;
        readBytes(): Promise<Uint8Array<ArrayBufferLike>>;
        readText(): Promise<string>;
        tee(): [ReadableStream<R>, ReadableStream<R>];
        values(
            options?: { preventCancel?: boolean },
        ): ReadableStreamAsyncIterator<R>;
    }

    Type Parameters

    • R = any

    Hierarchy

    • ReadableStream<R>
      • ModalReadStream
    Index

    Properties

    locked: boolean

    Methods

    • Returns ReadableStreamAsyncIterator<R>

    • Parameters

      • Optionalreason: any

      Returns Promise<void>

    • Parameters

      • options: { mode: "byob" }

      Returns ReadableStreamBYOBReader

    • Returns ReadableStreamDefaultReader<R>

    • Parameters

      • Optionaloptions: ReadableStreamGetReaderOptions

      Returns ReadableStreamReader<R>

    • Type Parameters

      • T

      Parameters

      • transform: ReadableWritablePair<T, R>
      • Optionaloptions: StreamPipeOptions

      Returns ReadableStream<T>

    • Parameters

      • destination: WritableStream<R>
      • Optionaloptions: StreamPipeOptions

      Returns Promise<void>

    • Read the entire stream as a byte array.

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Read the entire stream as a string.

      Returns Promise<string>

    • Returns [ReadableStream<R>, ReadableStream<R>]

    • Parameters

      • Optionaloptions: { preventCancel?: boolean }

      Returns ReadableStreamAsyncIterator<R>