Skip to content

Commit

Permalink
doc: fix process.stdin example
Browse files Browse the repository at this point in the history
Fixes: #20503

PR-URL: #25344
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
addaleax committed Jan 8, 2019
1 parent eaaaa0d commit 354fba1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions doc/api/process.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
});
Expand Down

0 comments on commit 354fba1

Please sign in to comment.