@reactivex/ix-es5-esm
Version:
The Interactive Extensions for JavaScript
88 lines (86 loc) • 3.69 kB
JavaScript
import { __extends, __generator, __values } from "tslib";
import { IterableX } from '../iterablex.js';
import { arrayIndexOf } from '../../util/arrayindexof.js';
import { comparer as defaultComparer } from '../../util/comparer.js';
/** @ignore */
var ExceptIterable = /** @class */ (function (_super) {
__extends(ExceptIterable, _super);
function ExceptIterable(first, second, comparer) {
var _this = _super.call(this) || this;
_this._first = first;
_this._second = second;
_this._comparer = comparer;
return _this;
}
ExceptIterable.prototype[Symbol.iterator] = function () {
var map, _a, _b, secondItem, _c, _d, firstItem, e_1_1;
var e_2, _e, e_1, _f;
return __generator(this, function (_g) {
switch (_g.label) {
case 0:
map = [];
try {
for (_a = __values(this._second), _b = _a.next(); !_b.done; _b = _a.next()) {
secondItem = _b.value;
map.push(secondItem);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
}
finally { if (e_2) throw e_2.error; }
}
_g.label = 1;
case 1:
_g.trys.push([1, 6, 7, 8]);
_c = __values(this._first), _d = _c.next();
_g.label = 2;
case 2:
if (!!_d.done) return [3 /*break*/, 5];
firstItem = _d.value;
if (!(arrayIndexOf(map, firstItem, this._comparer) === -1)) return [3 /*break*/, 4];
map.push(firstItem);
return [4 /*yield*/, firstItem];
case 3:
_g.sent();
_g.label = 4;
case 4:
_d = _c.next();
return [3 /*break*/, 2];
case 5: return [3 /*break*/, 8];
case 6:
e_1_1 = _g.sent();
e_1 = { error: e_1_1 };
return [3 /*break*/, 8];
case 7:
try {
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
}
finally { if (e_1) throw e_1.error; }
return [7 /*endfinally*/];
case 8: return [2 /*return*/];
}
});
};
return ExceptIterable;
}(IterableX));
export { ExceptIterable };
/**
* Produces the set difference of two iterable sequences by using the specified equality comparer to compare values.
*
* @template TSource The type of the elements of the input sequences.
* @param {Iterable<TSource>} second An 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} [comparer=defaultComparer] An equality comparer to compare values
* @returns {MonoTypeOperatorFunction<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 = defaultComparer; }
return function exceptOperatorFunction(first) {
return new ExceptIterable(first, second, comparer);
};
}
//# sourceMappingURL=except.js.map