Feature request: merge multiple async iterators
Closed this issue · 3 comments
pietercolpaert commented
A function merge
on an AsyncIterator would be a great tool to e.g., merge sort different iterators:
require('async-iterator').merge([iterators], function (a, b) { return a.departureTime < b.departureTime})
Which element is emitted next is based on a boolean condition.
RubenVerborgh commented
I think @rubensworks made a library that does this. Might be able to steal that code.
rubensworks commented
Yes, I made asynciterator-union, which takes the union of two streams, but it doesn't do sorting.
It should not be too hard to extend it with a comparator-based iterator though.
(Note to self: we may need a new abstraction, where both RoundRobinUnionIterator
and MergeSortUnionIterator
extend from it)
RubenVerborgh commented
Now also available in this library itself: f405a7d