Aller au contenu principal

streamToPort

Callable

  • streamToPort(stream: ReadableStream<Uint8Array>): MessagePort

  • Bridges a ReadableStream to a MessagePort by reading chunks and posting messages to the port. Used as a fallback when transferable streams are not supported (e.g., Safari).

    Protocol of the returned MessagePort:

    { t: 'chunk', b: ArrayBuffer } – next binary chunk { t: 'close' } – end of stream { t: 'error', m: string } – terminal error


    Parameters

    • stream: ReadableStream<Uint8Array>

    Returns MessagePort