Web Streams
WritableStream.getWriter()
Locks a writable stream for sequential writer operations. Release the lock after completion. Tested on Node.js 22.16.0. Example output (one line per entry): ["true", "false"].
Formal Syntax & Structure
nodejs syntaxnodejs
stream.getWriter()Return Value
WritableStreamDefaultWriter
Exclusive writer.
Working Example
Example Snippetnodejs
const s = new WritableStream();const w = s.getWriter();try { console.log(s.locked); await w.close();}finally { w.releaseLock();}console.log(s.locked);