From 20e27e18b16626ca2921a478680f6c34864a5518 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 --- 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 818bb6ed4ab73c..28ed9734f55144 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}`); } });