diff --git a/doc/api/stream.md b/doc/api/stream.md index 6f43d83fc31fa4..4a041e63ecc703 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -115,20 +115,20 @@ that implements an HTTP server: const http = require('http'); const server = http.createServer((req, res) => { - // `req` is an http.IncomingMessage, which is a Readable Stream - // `res` is an http.ServerResponse, which is a Writable Stream + // `req` is an http.IncomingMessage, which is a Readable Stream. + // `res` is an http.ServerResponse, which is a Writable Stream. let body = ''; // Get the data as utf8 strings. // If an encoding is not set, Buffer objects will be received. req.setEncoding('utf8'); - // Readable streams emit 'data' events once a listener is added + // Readable streams emit 'data' events once a listener is added. req.on('data', (chunk) => { body += chunk; }); - // The 'end' event indicates that the entire body has been received + // The 'end' event indicates that the entire body has been received. req.on('end', () => { try { const data = JSON.parse(body); @@ -250,7 +250,7 @@ function writeOneMillionTimes(writer, data, encoding, callback) { do { i--; if (i === 0) { - // last time! + // Last time! writer.write(data, encoding, callback); } else { // See if we should continue, or wait. @@ -259,8 +259,8 @@ function writeOneMillionTimes(writer, data, encoding, callback) { } } while (i > 0 && ok); if (i > 0) { - // had to stop early! - // write some more once it drains + // Had to stop early! + // Write some more once it drains. writer.once('drain', write); } } @@ -410,7 +410,7 @@ Calling the [`stream.write()`][stream-write] method after calling [`stream.end()`][stream-end] will raise an error. ```js -// Write 'hello, ' and then end with 'world!' +// Write 'hello, ' and then end with 'world!'. const fs = require('fs'); const file = fs.createWriteStream('example.txt'); file.write('hello, '); @@ -480,6 +480,15 @@ added: v11.4.0 Is `true` if it is safe to call [`writable.write()`][stream-write]. +##### writable.writableFinished + + +* {boolean} + +Is `true` if after the [`'finish'`][] event has been emitted. + ##### writable.writableHighWaterMark - -* {boolean} - -Is `true` if all data has been flushed to the underlying system. After -the [`'finish'`][] event has been emitted. - ##### writable.writableObjectMode