Web Streams
WritableStreamDefaultWriter.write()
Returns a promise for the sink operation. Await it to avoid accumulating unlimited pending writes. Tested on Node.js 22.16.0. Example output (one line per entry): ["one,two"].
Formal Syntax & Structure
nodejs syntaxnodejs
writer.write(chunk)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| chunk | unknown | Data for the underlying sink. |
Return Value
Promise<void>
Write completion.
Working Example
Example Snippetnodejs
const values = [];const w = new WritableStream({ write(v) { values.push(v); } }).getWriter();try { await w.write('one'); await w.write('two'); await w.close(); console.log(values.join(','));}finally { w.releaseLock();}