diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-01-04 19:21:27 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-01-08 00:33:58 +0100 |
commit | 86ae2c182b425e08e8a98fcd47220d452cc94f53 (patch) | |
tree | 818573169b455c44e76f7cbc42300f8baf8fbaee /doc | |
parent | 9db9e7e541c1ff9a30b7f1b61c6d3a7b6d30fab3 (diff) | |
download | android-node-v8-86ae2c182b425e08e8a98fcd47220d452cc94f53.tar.gz android-node-v8-86ae2c182b425e08e8a98fcd47220d452cc94f53.tar.bz2 android-node-v8-86ae2c182b425e08e8a98fcd47220d452cc94f53.zip |
doc: fix process.stdin example
Fixes: https://github.com/nodejs/node/issues/20503
PR-URL: https://github.com/nodejs/node/pull/25344
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/process.md | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/doc/api/process.md b/doc/api/process.md index 818bb6ed4a..28ed9734f5 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1856,8 +1856,9 @@ a [Readable][] stream. process.stdin.setEncoding('utf8'); process.stdin.on('readable', () => { - const chunk = process.stdin.read(); - if (chunk !== null) { + let chunk; + // Use a loop to make sure we read all available data. + while ((chunk = process.stdin.read()) !== null) { process.stdout.write(`data: ${chunk}`); } }); |