Web APIs
WritableStreamDefaultWriter.prototype.write()
Queues a chunk and returns a promise for its successful processing or failure.
Formal Syntax & Structure
javascript syntaxjavascript
writer.write(chunk)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| chunk | any | Chunk to send to the sink. |
Return Value
Promise<undefined>
Queues a chunk and returns a promise for its successful processing or failure.
Working Example
Example Snippetjavascript
(async () => {const out=[];const s=new WritableStream({write(v){out.push(v);},close(){out.push("end");}});const w=s.getWriter();await w.write("a");await w.write("b");await w.close();w.releaseLock();console.log(JSON.stringify(out));})()