Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add fs declarations to stream doc js examples #18804

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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