1 | import { AsyncIterableX } from './asynciterablex';
|
2 | import { arrayIndexOfAsync } from '../internal/arrayindexof';
|
3 | import { comparerAsync } from '../internal/comparer';
|
4 | export 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 | }
|
24 | export function except(first, second, comparer = comparerAsync) {
|
25 | return new ExceptAsyncIterable(first, second, comparer);
|
26 | }
|
27 |
|
28 |
|