Skip to main content

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

Type Parameters​

Type ParameterDefault type
Wany

Methods​

abort()​

abort(reason?): 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.

MDN Reference

Parameters​

ParameterType
reason?any

Returns​

Promise<void>


close()​

close(): Promise<void>;

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

MDN Reference

Returns​

Promise<void>


releaseLock()​

releaseLock(): void;

The releaseLock() method of the WritableStreamDefaultWriter interface releases the writer's lock on the corresponding stream. After the lock is released, the writer is no longer active. If the associated stream is errored when the lock is released, the writer will appear errored in the same way from now on; otherwise, the writer will appear closed.

MDN Reference

Returns​

void


write()​

write(chunk?): 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.

MDN Reference

Parameters​

ParameterType
chunk?W

Returns​

Promise<void>

Properties​

closed​

readonly closed: Promise<void>;

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.

MDN Reference


desiredSize​

readonly desiredSize: number | null;

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

MDN Reference


ready​

readonly ready: Promise<void>;

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.

MDN Reference