diff --git a/doc/api/webstreams.md b/doc/api/webstreams.md index a5089796c219ad..f5b2496036fe7c 100644 --- a/doc/api/webstreams.md +++ b/doc/api/webstreams.md @@ -436,6 +436,41 @@ async function* asyncIterableGenerator() { })(); ``` +To pipe the resulting {ReadableStream} into a {WritableStream} the {Iterable} +should yield a sequence of {Buffer}, {TypedArray}, or {DataView} objects. + +```mjs +import { ReadableStream } from 'node:stream/web'; +import { Buffer } from 'node:buffer'; + +async function* asyncIterableGenerator() { + yield Buffer.from('a'); + yield Buffer.from('b'); + yield Buffer.from('c'); +} + +const stream = ReadableStream.from(asyncIterableGenerator()); + +await stream.pipeTo(createWritableStreamSomehow()); +``` + +```cjs +const { ReadableStream } = require('node:stream/web'); +const { Buffer } = require('node:buffer'); + +async function* asyncIterableGenerator() { + yield Buffer.from('a'); + yield Buffer.from('b'); + yield Buffer.from('c'); +} + +const stream = ReadableStream.from(asyncIterableGenerator()); + +(async () => { + await stream.pipeTo(createWritableStreamSomehow()); +})(); +``` + ### Class: `ReadableStreamDefaultReader`