Skip to content

Commit ed55386

Browse files
prog1devtargos
authored andcommitted
doc: add fs declarations to stream doc js examples
PR-URL: #18804 Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
1 parent 9c67262 commit ed55386

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

doc/api/stream.md

+4
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ Calling the [`stream.write()`][stream-write] method after calling
381381

382382
```js
383383
// write 'hello, ' and then end with 'world!'
384+
const fs = require('fs');
384385
const file = fs.createWriteStream('example.txt');
385386
file.write('hello, ');
386387
file.end('world!');
@@ -858,6 +859,7 @@ The following example pipes all of the data from the `readable` into a file
858859
named `file.txt`:
859860

860861
```js
862+
const fs = require('fs');
861863
const readable = getReadableStreamSomehow();
862864
const writable = fs.createWriteStream('file.txt');
863865
// All the data from readable goes into 'file.txt'
@@ -869,6 +871,7 @@ The `readable.pipe()` method returns a reference to the *destination* stream
869871
making it possible to set up chains of piped streams:
870872

871873
```js
874+
const fs = require('fs');
872875
const r = fs.createReadStream('file.txt');
873876
const z = zlib.createGzip();
874877
const w = fs.createWriteStream('file.txt.gz');
@@ -1029,6 +1032,7 @@ If the `destination` is specified, but no pipe is set up for it, then
10291032
the method does nothing.
10301033

10311034
```js
1035+
const fs = require('fs');
10321036
const readable = getReadableStreamSomehow();
10331037
const writable = fs.createWriteStream('file.txt');
10341038
// All the data from readable goes into 'file.txt',

0 commit comments

Comments
 (0)