toReadable(source[, options])


稳定性: 1 - 实验性

AsyncIterable<Uint8Array[]> 创建一个字节模式的 stream.Readable(流/迭代 API 使用的本地批处理格式)。在生成的批处理中,每个 Uint8Array 都会作为单独的块推送到可读对象中。

🌐 Creates a byte-mode stream.Readable from an AsyncIterable<Uint8Array[]> (the native batch format used by the stream/iter API). Each Uint8Array in a yielded batch is pushed as a separate chunk into the Readable.

import { createWriteStream } from 'node:fs';
import { from, pull, toReadable } from 'node:stream/iter';
import { compressGzip } from 'node:zlib/iter';

const source = pull(from('hello world'), compressGzip());
const readable = toReadable(source);

readable.pipe(createWriteStream('output.gz'));const { createWriteStream } = require('node:fs');
const { from, pull, toReadable } = require('node:stream/iter');
const { compressGzip } = require('node:zlib/iter');

const source = pull(from('hello world'), compressGzip());
const readable = toReadable(source);

readable.pipe(createWriteStream('output.gz'));