WritableStreamDefaultWriter
object cannot be constructed directly. You can use the WritableStream.getWriter method to construct a WritableStreamDefaultWriter
object.// Use TransformStream to construct a WritableStream object.const { writable } = new TransformStream();// Use the WritableStream object to obtain the writer.const writer = writable.getWriter();
// writer.closedreadonly closed: Promise<void>;
fulfilled
. If an exception occurs on the lock on the writer is released, the status of the Promise object is rejected
.// writer.readyreadonly ready: Promise<void>;
// writer.desiredSizereadonly desiredSize: number;
writer.write(chunk: Chunk): Promise<void>;
Chunk
data to the stream.write
method to initiate the next stream writing operation until the current stream writing operation ends.Parameter | Type | Required | Description |
chunk | Yes | The chunk of data to be written to the stream. |
Chunk
parameter indicates the data to be written to the stream.type Chunk = string | ArrayBuffer | ArrayBufferView;
writer.close(): Promise<void>;
writer.abort(reason?: string): Promise<string>;
writer.releaseLock(): void;
Was this page helpful?