@reactivex/ix-esnext-esm
Version:
The Interactive Extensions for JavaScript
31 lines (29 loc) • 1.01 kB
JavaScript
import { AsyncIterableX } from '../asynciterablex';
import { arrayIndexOfAsync } from '../../util/arrayindexof';
import { comparerAsync } from '../../util/comparer';
export class ExceptAsyncIterable extends AsyncIterableX {
constructor(first, second, comparer) {
super();
this._first = first;
this._second = second;
this._comparer = comparer;
}
async *[Symbol.asyncIterator]() {
const map = [];
for await (const secondItem of this._second) {
map.push(secondItem);
}
for await (const firstItem of this._first) {
if ((await arrayIndexOfAsync(map, firstItem, this._comparer)) === -1) {
map.push(firstItem);
yield firstItem;
}
}
}
}
export function except(second, comparer = comparerAsync) {
return function exceptOperatorFunction(first) {
return new ExceptAsyncIterable(first, second, comparer);
};
}
//# sourceMappingURL=except.mjs.map