UNPKG

@reactivex/ix-es5-esm

Version:

The Interactive Extensions for JavaScript

85 lines (83 loc) 3.82 kB
import { __asyncGenerator, __asyncValues, __await, __extends, __generator } from "tslib"; import { AsyncIterableX } from '../asynciterablex.js'; import { wrapWithAbort } from './withabort.js'; import { throwIfAborted } from '../../aborterror.js'; /** @ignore */ var SkipUntilAsyncIterable = /** @class */ (function (_super) { __extends(SkipUntilAsyncIterable, _super); function SkipUntilAsyncIterable(source, other) { var _this = _super.call(this) || this; _this._source = source; _this._other = other; return _this; } SkipUntilAsyncIterable.prototype[Symbol.asyncIterator] = function (signal) { return __asyncGenerator(this, arguments, function _a() { var otherDone, _b, _c, _d, item, e_1_1; var _e, e_1, _f, _g; return __generator(this, function (_h) { switch (_h.label) { case 0: throwIfAborted(signal); otherDone = false; this._other(signal).then(function () { return (otherDone = true); }); _h.label = 1; case 1: _h.trys.push([1, 8, 9, 14]); _b = true, _c = __asyncValues(wrapWithAbort(this._source, signal)); _h.label = 2; case 2: return [4 /*yield*/, __await(_c.next())]; case 3: if (!(_d = _h.sent(), _e = _d.done, !_e)) return [3 /*break*/, 7]; _g = _d.value; _b = false; item = _g; if (!otherDone) return [3 /*break*/, 6]; return [4 /*yield*/, __await(item)]; case 4: return [4 /*yield*/, _h.sent()]; case 5: _h.sent(); _h.label = 6; case 6: _b = true; return [3 /*break*/, 2]; case 7: return [3 /*break*/, 14]; case 8: e_1_1 = _h.sent(); e_1 = { error: e_1_1 }; return [3 /*break*/, 14]; case 9: _h.trys.push([9, , 12, 13]); if (!(!_b && !_e && (_f = _c.return))) return [3 /*break*/, 11]; return [4 /*yield*/, __await(_f.call(_c))]; case 10: _h.sent(); _h.label = 11; case 11: return [3 /*break*/, 13]; case 12: if (e_1) throw e_1.error; return [7 /*endfinally*/]; case 13: return [7 /*endfinally*/]; case 14: return [2 /*return*/]; } }); }); }; return SkipUntilAsyncIterable; }(AsyncIterableX)); export { SkipUntilAsyncIterable }; /** * Returns the elements from the source observable sequence only after the function that returns a promise produces an element. * * @template TSource The type of the elements in the source sequence. * @param {(signal?: AbortSignal) => Promise<any>} other A function which returns a promise that triggers propagation * of elements of the source sequence. * @returns {MonoTypeOperatorAsyncFunction<TSource>} An async-iterable sequence containing the elements of the source sequence * starting from the point the function that returns a promise triggered propagation. */ export function skipUntil(other) { return function skipUntilOperatorFunction(source) { return new SkipUntilAsyncIterable(source, other); }; } //# sourceMappingURL=skipuntil.js.map