@reactivex/ix-esnext-esm
Version:
The Interactive Extensions for JavaScript
34 lines (32 loc) • 1.03 kB
JavaScript
import { IterableX } from '../iterablex';
import { arrayIndexOf } from '../../util/arrayindexof';
import { comparer as defaultComparer } from '../../util/comparer';
export class UnionIterable extends IterableX {
constructor(left, right, comparer) {
super();
this._left = left;
this._right = right;
this._comparer = comparer;
}
*[Symbol.iterator]() {
const map = [];
for (const lItem of this._left) {
if (arrayIndexOf(map, lItem, this._comparer) === -1) {
map.push(lItem);
yield lItem;
}
}
for (const rItem of this._right) {
if (arrayIndexOf(map, rItem, this._comparer) === -1) {
map.push(rItem);
yield rItem;
}
}
}
}
export function union(right, comparer = defaultComparer) {
return function unionOperatorFunction(left) {
return new UnionIterable(left, right, comparer);
};
}
//# sourceMappingURL=union.mjs.map