GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: add example for piping ReadableStream · nodejs/node@03df76c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • webstreams.md
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/webstreams.md‎

Copy file name to clipboardExpand all lines: doc/api/webstreams.md
+35Lines changed: 35 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,41 @@ async function* asyncIterableGenerator() {
436436
})();
437437
```
438438

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+
439474
### Class: `ReadableStreamDefaultReader`
440475

441476
<!-- YAML

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.