A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/nodejs/node/commit/03df76cdec below:

add example for piping ReadableStream · nodejs/node@03df76c · GitHub

File tree Expand file treeCollapse file tree 1 file changed

+35

-0

lines changed

Filter options

Expand file treeCollapse file tree 1 file changed

+35

-0

lines changed Original file line number Diff line number Diff line change

@@ -436,6 +436,41 @@ async function* asyncIterableGenerator() {

436 436

})();

437 437

```

438 438 439 +

To pipe the resulting {ReadableStream} into a {WritableStream} the {Iterable}

440 +

should yield a sequence of {Buffer}, {TypedArray}, or {DataView} objects.

441 + 442 +

```mjs

443 +

import { ReadableStream } from 'node:stream/web';

444 +

import { Buffer } from 'node:buffer';

445 + 446 +

async function* asyncIterableGenerator() {

447 +

yield Buffer.from('a');

448 +

yield Buffer.from('b');

449 +

yield Buffer.from('c');

450 +

}

451 + 452 +

const stream = ReadableStream.from(asyncIterableGenerator());

453 + 454 +

await stream.pipeTo(createWritableStreamSomehow());

455 +

```

456 + 457 +

```cjs

458 +

const { ReadableStream } = require('node:stream/web');

459 +

const { Buffer } = require('node:buffer');

460 + 461 +

async function* asyncIterableGenerator() {

462 +

yield Buffer.from('a');

463 +

yield Buffer.from('b');

464 +

yield Buffer.from('c');

465 +

}

466 + 467 +

const stream = ReadableStream.from(asyncIterableGenerator());

468 + 469 +

(async () => {

470 +

await stream.pipeTo(createWritableStreamSomehow());

471 +

})();

472 +

```

473 + 439 474

### Class: `ReadableStreamDefaultReader`

440 475 441 476

<!-- YAML

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4