merge(...sources[, options])
...sourcesAsyncIterable|Iterable 两个或更多可迭代对象。 options<Object>signal<AbortSignal>
- 返回:AsyncIterable
通过按时间顺序产出批次来合并多个异步可迭代对象(无论哪个源先产生数据)。所有源都同时被消费。
🌐 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);