WritableStreamDefaultWriter

The WritableStreamDefaultWriter interface of the Streams API is the object returned by WritableStream.getWriter() and once created locks the writer to the WritableStream ensuring that no other streams can write to the underlying sink.

MDN Reference

Constructors

Link copied to clipboard
constructor(stream: WritableStream<W>)

Properties

Link copied to clipboard

The closed read-only property of the WritableStreamDefaultWriter interface returns a Promise that fulfills if the stream becomes closed, or rejects if the stream errors or the writer's lock is released.

Link copied to clipboard

The desiredSize read-only property of the WritableStreamDefaultWriter interface returns the desired size required to fill the stream's internal queue.

Link copied to clipboard

The ready read-only property of the WritableStreamDefaultWriter interface returns a Promise that resolves when the desired size of the stream's internal queue transitions from non-positive to positive, signaling that it is no longer applying backpressure.

Functions

Link copied to clipboard
inline suspend fun <W : JsAny?> WritableStreamDefaultWriter<W>.abort()
inline suspend fun <W : JsAny?> WritableStreamDefaultWriter<W>.abort(reason: JsError?)

The abort() method of the WritableStreamDefaultWriter interface aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded.

Link copied to clipboard
fun abortAsync(reason: JsError? = definedExternally): Promise<Void?>

The abort() method of the WritableStreamDefaultWriter interface aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be immediately moved to an error state, with any queued writes discarded.

Link copied to clipboard
inline suspend fun <W : JsAny?> WritableStreamDefaultWriter<W>.close()

The close() method of the WritableStreamDefaultWriter interface closes the associated writable stream.

Link copied to clipboard

The close() method of the WritableStreamDefaultWriter interface closes the associated writable stream.

Link copied to clipboard

The releaseLock() method of the WritableStreamDefaultWriter interface releases the writer's lock on the corresponding stream.

Link copied to clipboard
inline suspend fun <W : JsAny?> WritableStreamDefaultWriter<W>.write()
inline suspend fun <W : JsAny?> WritableStreamDefaultWriter<W>.write(chunk: W)

The write() method of the WritableStreamDefaultWriter interface writes a passed chunk of data to a WritableStream and its underlying sink, then returns a Promise that resolves to indicate the success or failure of the write operation.

Link copied to clipboard
fun writeAsync(chunk: W = definedExternally): Promise<Void?>

The write() method of the WritableStreamDefaultWriter interface writes a passed chunk of data to a WritableStream and its underlying sink, then returns a Promise that resolves to indicate the success or failure of the write operation.