UNPKG

946 BJavaScriptView Raw
1import { AsyncIterableX } from './asynciterablex';
2import { arrayIndexOfAsync } from '../internal/arrayindexof';
3import { comparerAsync } from '../internal/comparer';
4export class ExceptAsyncIterable extends AsyncIterableX {
5 constructor(first, second, comparer) {
6 super();
7 this._first = first;
8 this._second = second;
9 this._comparer = comparer;
10 }
11 async *[Symbol.asyncIterator]() {
12 let map = [];
13 for await (let secondItem of this._second) {
14 map.push(secondItem);
15 }
16 for await (let firstItem of this._first) {
17 if ((await arrayIndexOfAsync(map, firstItem, this._comparer)) === -1) {
18 map.push(firstItem);
19 yield firstItem;
20 }
21 }
22 }
23}
24export function except(first, second, comparer = comparerAsync) {
25 return new ExceptAsyncIterable(first, second, comparer);
26}
27
28//# sourceMappingURL=except.mjs.map