Web APIs
WritableStreamDefaultWriter.close()
Request normal closure after queued writes finish. The returned promise settles when closure succeeds or fails. Example console output: A,closed.
Formal Syntax & Structure
javascript syntaxjavascript
writer.close()Return Value
Promise<undefined>
Completion of the close operation.
Working Example
Example Snippetjavascript
(async () => {const log=[]; const w=new WritableStream({write(x){log.push(x)},close(){log.push("closed")}}).getWriter(); await w.write("A"); await w.close(); console.log(log.join(",")); w.releaseLock();})()