UNPKG

@reactivex/ix-es5-esm

Version:

The Interactive Extensions for JavaScript

124 lines (122 loc) 5.82 kB
import { __asyncGenerator, __asyncValues, __await, __extends, __generator } from "tslib"; import { AsyncIterableX } from '../asynciterablex.js'; import { arrayIndexOfAsync } from '../../util/arrayindexof.js'; import { comparerAsync } from '../../util/comparer.js'; import { wrapWithAbort } from './withabort.js'; import { throwIfAborted } from '../../aborterror.js'; /** @ignore */ var ExceptAsyncIterable = /** @class */ (function (_super) { __extends(ExceptAsyncIterable, _super); function ExceptAsyncIterable(first, second, comparer) { var _this = _super.call(this) || this; _this._first = first; _this._second = second; _this._comparer = comparer; return _this; } ExceptAsyncIterable.prototype[Symbol.asyncIterator] = function (signal) { return __asyncGenerator(this, arguments, function _a() { var map, _b, _c, _d, secondItem, e_1_1, _e, _f, _g, firstItem, e_2_1; var _h, e_1, _j, _k, _l, e_2, _m, _o; return __generator(this, function (_p) { switch (_p.label) { case 0: throwIfAborted(signal); map = []; _p.label = 1; case 1: _p.trys.push([1, 6, 7, 12]); _b = true, _c = __asyncValues(wrapWithAbort(this._second, signal)); _p.label = 2; case 2: return [4 /*yield*/, __await(_c.next())]; case 3: if (!(_d = _p.sent(), _h = _d.done, !_h)) return [3 /*break*/, 5]; _k = _d.value; _b = false; secondItem = _k; map.push(secondItem); _p.label = 4; case 4: _b = true; return [3 /*break*/, 2]; case 5: return [3 /*break*/, 12]; case 6: e_1_1 = _p.sent(); e_1 = { error: e_1_1 }; return [3 /*break*/, 12]; case 7: _p.trys.push([7, , 10, 11]); if (!(!_b && !_h && (_j = _c.return))) return [3 /*break*/, 9]; return [4 /*yield*/, __await(_j.call(_c))]; case 8: _p.sent(); _p.label = 9; case 9: return [3 /*break*/, 11]; case 10: if (e_1) throw e_1.error; return [7 /*endfinally*/]; case 11: return [7 /*endfinally*/]; case 12: _p.trys.push([12, 20, 21, 26]); _e = true, _f = __asyncValues(wrapWithAbort(this._first, signal)); _p.label = 13; case 13: return [4 /*yield*/, __await(_f.next())]; case 14: if (!(_g = _p.sent(), _l = _g.done, !_l)) return [3 /*break*/, 19]; _o = _g.value; _e = false; firstItem = _o; return [4 /*yield*/, __await(arrayIndexOfAsync(map, firstItem, this._comparer))]; case 15: if (!((_p.sent()) === -1)) return [3 /*break*/, 18]; map.push(firstItem); return [4 /*yield*/, __await(firstItem)]; case 16: return [4 /*yield*/, _p.sent()]; case 17: _p.sent(); _p.label = 18; case 18: _e = true; return [3 /*break*/, 13]; case 19: return [3 /*break*/, 26]; case 20: e_2_1 = _p.sent(); e_2 = { error: e_2_1 }; return [3 /*break*/, 26]; case 21: _p.trys.push([21, , 24, 25]); if (!(!_e && !_l && (_m = _f.return))) return [3 /*break*/, 23]; return [4 /*yield*/, __await(_m.call(_f))]; case 22: _p.sent(); _p.label = 23; case 23: return [3 /*break*/, 25]; case 24: if (e_2) throw e_2.error; return [7 /*endfinally*/]; case 25: return [7 /*endfinally*/]; case 26: return [2 /*return*/]; } }); }); }; return ExceptAsyncIterable; }(AsyncIterableX)); export { ExceptAsyncIterable }; /** * Produces the set difference of two async-iterable sequences by using the specified equality comparer to compare values. * * @template TSource The type of the elements of the input sequences. * @param {AsyncIterable<TSource>} second An async-iterable sequence whose elements that also occur in the * operator sequence will cause those elements to be removed from the returned sequence. * @param {((x: TSource, y: TSource) => boolean | Promise<boolean>)} [comparer=comparerAsync] An equality comparer to compare values * @returns {MonoTypeOperatorAsyncFunction<TSource>} An operator that returns a sequence that contains the set * difference of the elements of two sequences. */ export function except(second, comparer) { if (comparer === void 0) { comparer = comparerAsync; } return function exceptOperatorFunction(first) { return new ExceptAsyncIterable(first, second, comparer); }; } //# sourceMappingURL=except.js.map