Options
All
  • Public
  • Public/Protected
  • All
Menu

Class WritableStream<W>

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

Type parameters

  • W = any

Hierarchy

  • WritableStream

Index

Constructors

Accessors

Methods

Constructors

constructor

Accessors

locked

  • get locked(): boolean
  • Returns whether or not the writable stream is locked to a writer.

    Returns boolean

Methods

abort

  • abort(reason?: any): Promise<void>
  • 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<void>

close

  • close(): Promise<void>
  • 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<void>

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