A fan-in multiplexer that merges multiple ReadableStream inputs into a single output ReadableStream. Inputs can be dynamically added and removed at any time while the stream is open.

Unlike DeferredReadableStream which supports a single readable source, MultiInputStream allows N concurrent input streams to pump data into one output.

Key behaviors:

  • An error in one input removes that input but does not kill the output.
  • When all inputs end or are removed, the output stays open (waiting for new inputs).
  • The output only closes when close is called explicitly.
  • removeInputStream releases the reader lock so the source can be reused.

Type Parameters

  • T

Constructors

Accessors

Methods

  • Add an input ReadableStream that will be pumped into the output.

    Parameters

    • source: ReadableStream<T>

    Returns string

    A unique identifier that can be passed to removeInputStream.

    Throws

    If the stream has already been closed.

  • Detach an input stream by its ID and release the reader lock so the source stream can be reused elsewhere.

    No-op if the ID does not exist (e.g. the input already ended or was removed).

    Parameters

    • id: string

    Returns Promise<void>