Skip to content

Commit b5b5f9f

Browse files
grantcarthewBridgeAR
authored andcommitted
doc: fix code examples in stream.md
* Replace `console.error()` with `console.log()`. * Fix case and punctuation in logged output. PR-URL: #24112 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
1 parent 8de1030 commit b5b5f9f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

doc/api/stream.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ for (let i = 0; i < 100; i++) {
291291
}
292292
writer.end('This is the end\n');
293293
writer.on('finish', () => {
294-
console.error('All writes are now complete.');
294+
console.log('All writes are now complete.');
295295
});
296296
```
297297

@@ -309,7 +309,7 @@ a readable stream, adding this writable to its set of destinations.
309309
const writer = getWritableStreamSomehow();
310310
const reader = getReadableStreamSomehow();
311311
writer.on('pipe', (src) => {
312-
console.error('something is piping into the writer');
312+
console.log('Something is piping into the writer.');
313313
assert.equal(src, reader);
314314
});
315315
reader.pipe(writer);
@@ -334,7 +334,7 @@ This is also emitted in case this [`Writable`][] stream emits an error when a
334334
const writer = getWritableStreamSomehow();
335335
const reader = getReadableStreamSomehow();
336336
writer.on('unpipe', (src) => {
337-
console.error('Something has stopped piping into the writer.');
337+
console.log('Something has stopped piping into the writer.');
338338
assert.equal(src, reader);
339339
});
340340
reader.pipe(writer);
@@ -551,7 +551,7 @@ function write(data, cb) {
551551

552552
// Wait for cb to be called before doing any other write.
553553
write('hello', () => {
554-
console.log('write completed, do more writes now');
554+
console.log('Write completed, do more writes now.');
555555
});
556556
```
557557

@@ -1091,7 +1091,7 @@ const readable = getReadableStreamSomehow();
10911091
readable.setEncoding('utf8');
10921092
readable.on('data', (chunk) => {
10931093
assert.equal(typeof chunk, 'string');
1094-
console.log('got %d characters of string data', chunk.length);
1094+
console.log('Got %d characters of string data:', chunk.length);
10951095
});
10961096
```
10971097

@@ -1119,9 +1119,9 @@ const writable = fs.createWriteStream('file.txt');
11191119
// but only for the first second
11201120
readable.pipe(writable);
11211121
setTimeout(() => {
1122-
console.log('Stop writing to file.txt');
1122+
console.log('Stop writing to file.txt.');
11231123
readable.unpipe(writable);
1124-
console.log('Manually close the file stream');
1124+
console.log('Manually close the file stream.');
11251125
writable.end();
11261126
}, 1000);
11271127
```
@@ -1338,9 +1338,9 @@ const rs = fs.createReadStream('archive.tar');
13381338

13391339
finished(rs, (err) => {
13401340
if (err) {
1341-
console.error('Stream failed', err);
1341+
console.error('Stream failed.', err);
13421342
} else {
1343-
console.log('Stream is done reading');
1343+
console.log('Stream is done reading.');
13441344
}
13451345
});
13461346

@@ -1360,7 +1360,7 @@ const rs = fs.createReadStream('archive.tar');
13601360

13611361
async function run() {
13621362
await finished(rs);
1363-
console.log('Stream is done reading');
1363+
console.log('Stream is done reading.');
13641364
}
13651365

13661366
run().catch(console.error);
@@ -1395,9 +1395,9 @@ pipeline(
13951395
fs.createWriteStream('archive.tar.gz'),
13961396
(err) => {
13971397
if (err) {
1398-
console.error('Pipeline failed', err);
1398+
console.error('Pipeline failed.', err);
13991399
} else {
1400-
console.log('Pipeline succeeded');
1400+
console.log('Pipeline succeeded.');
14011401
}
14021402
}
14031403
);
@@ -1414,7 +1414,7 @@ async function run() {
14141414
zlib.createGzip(),
14151415
fs.createWriteStream('archive.tar.gz')
14161416
);
1417-
console.log('Pipeline succeeded');
1417+
console.log('Pipeline succeeded.');
14181418
}
14191419

14201420
run().catch(console.error);

0 commit comments

Comments
 (0)