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>
This commit is contained in:
parent
9db9e7e541
commit
86ae2c182b
@ -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}`);
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user