merge(...sources[, options])
...sources<AsyncIterable> | <Iterable> 它的块必须是 <Uint8Array[]>options<Object>signal<AbortSignal>
- 返回:<AsyncIterable> 它的块用 <Uint8Array[]> 填充
通过按时间顺序产出批次来合并多个异步可迭代对象(无论哪个源先产生数据)。所有源都同时被消费。
🌐 Merge multiple async iterables by yielding batches in temporal order (whichever source produces data first). All sources are consumed concurrently.
import { from, merge, text } from 'node:stream/iter';
const merged = merge(from('hello '), from('world'));
console.log(await text(merged)); // Order depends on timingconst { from, merge, text } = require('node:stream/iter');
async function run() {
const merged = merge(from('hello '), from('world'));
console.log(await text(merged)); // Order depends on timing
}
run().catch(console.error);