Options
All
  • Public
  • Public/Protected
  • All
Menu

A writable stream represents a destination for data, into which you can write.

Type parameters

  • W = any

Hierarchy

  • WritableStream

Index

Constructors

Properties

Methods

Constructors

constructor

  • Type parameters

    • W = any

    Parameters

    Returns WritableStream<W>

Properties

Readonly locked

locked: boolean

Returns whether or not the writable stream is locked to a writer.

Methods

abort

  • abort(reason?: any): Promise<undefined>
  • Aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an errored state, with any queued-up writes discarded. This will also execute any abort mechanism of the underlying sink.

    The returned promise will fulfill if the stream shuts down successfully, or reject if the underlying sink signaled that there was an error doing so. Additionally, it will reject with a TypeError (without attempting to cancel the stream) if the stream is currently locked.

    Parameters

    • Optional reason: any

    Returns Promise<undefined>

close

  • close(): Promise<undefined>
  • Closes the stream. The underlying sink will finish processing any previously-written chunks, before invoking its close behavior. During this time any further attempts to write will fail (without erroring the stream).

    The method returns a promise that will fulfill if all remaining chunks are successfully written and the stream successfully closes, or rejects if an error is encountered during this process. Additionally, it will reject with a TypeError (without attempting to cancel the stream) if the stream is currently locked.

    Returns Promise<undefined>

getWriter

  • Creates a writer and locks the stream to the new writer. While the stream is locked, no other writer can be acquired until this one is released.

    This functionality is especially useful for creating abstractions that desire the ability to write to a stream without interruption or interleaving. By getting a writer for the stream, you can ensure nobody else can write at the same time, which would cause the resulting written data to be unpredictable and probably useless.

    Returns WritableStreamDefaultWriter<W>

Generated using TypeDoc