Skip to content

Commit

Permalink
doc: add fs declarations to stream doc js examples
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
prog1dev authored and vsemozhetbyt committed Feb 16, 2018
1 parent 94e8d2a commit 755d805
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ Calling the [`stream.write()`][stream-write] method after calling

```js
// write 'hello, ' and then end with 'world!'
const fs = require('fs');
const file = fs.createWriteStream('example.txt');
file.write('hello, ');
file.end('world!');
Expand Down Expand Up @@ -861,6 +862,7 @@ The following example pipes all of the data from the `readable` into a file
named `file.txt`:

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

```js
const fs = require('fs');
const r = fs.createReadStream('file.txt');
const z = zlib.createGzip();
const w = fs.createWriteStream('file.txt.gz');
Expand Down Expand Up @@ -1036,6 +1039,7 @@ If the `destination` is specified, but no pipe is set up for it, then
the method does nothing.

```js
const fs = require('fs');
const readable = getReadableStreamSomehow();
const writable = fs.createWriteStream('file.txt');
// All the data from readable goes into 'file.txt',
Expand Down Expand Up @@ -1173,6 +1177,8 @@ added: REPLACEME
Returns an [AsyncIterator][async-iterator] to fully consume the stream.

```js
const fs = require('fs');

async function print(readable) {
readable.setEncoding('utf8');
let data = '';
Expand Down

0 comments on commit 755d805

Please sign in to comment.