From 8d5ac6c8ef9a98ff58ea55a3dd1420159484053f Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 4 Jan 2019 19:21:27 +0100 Subject: [PATCH] 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 Reviewed-By: Matteo Collina Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Anto Aravinth Reviewed-By: Franziska Hinkelmann Reviewed-By: James M Snell --- doc/api/process.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/api/process.md b/doc/api/process.md index af5694b9391458..2bcaad21b023c8 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1863,8 +1863,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}`); } });