UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

34 lines (32 loc) 1.09 kB
import { AsyncIterableX } from '../asynciterablex'; import { arrayIndexOfAsync } from '../../util/arrayindexof'; import { comparerAsync } from '../../util/comparer'; export class UnionAsyncIterable extends AsyncIterableX { constructor(left, right, comparer) { super(); this._left = left; this._right = right; this._comparer = comparer; } async *[Symbol.asyncIterator]() { const map = []; for await (const lItem of this._left) { if ((await arrayIndexOfAsync(map, lItem, this._comparer)) === -1) { map.push(lItem); yield lItem; } } for await (const rItem of this._right) { if ((await arrayIndexOfAsync(map, rItem, this._comparer)) === -1) { map.push(rItem); yield rItem; } } } } export function union(right, comparer = comparerAsync) { return function unionOperatorFunction(left) { return new UnionAsyncIterable(left, right, comparer); }; } //# sourceMappingURL=union.mjs.map