Web APIs

WritableStreamDefaultWriter.prototype.write()

Try the free JavaScript compiler

Queues a chunk and returns a promise for its successful processing or failure.

Formal Syntax & Structure

javascript syntaxjavascript
writer.write(chunk)

Parameters & Attributes

NameTypeDescription
chunkanyChunk 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));})()
JavaScript Reference