toReadableSync(source[, options])


稳定性: 1 - 实验性

从同步的 Iterable<Uint8Array[]> 创建一个字节模式 stream.Readable_read() 方法同步地从迭代器中获取数据,因此可以通过 readable.read() 立即使用数据。

🌐 Creates a byte-mode stream.Readable from a synchronous Iterable<Uint8Array[]>. The _read() method pulls from the iterator synchronously, so data is available immediately via readable.read().

import { fromSync, toReadableSync } from 'node:stream/iter';

const source = fromSync('hello world');
const readable = toReadableSync(source);

console.log(readable.read().toString()); // 'hello world'const { fromSync, toReadableSync } = require('node:stream/iter');

const source = fromSync('hello world');
const readable = toReadableSync(source);

console.log(readable.read().toString()); // 'hello world'