UNPKG

@reactivex/ix-es5-esm

Version:

The Interactive Extensions for JavaScript

125 lines (123 loc) 5.38 kB
import { __asyncGenerator, __await, __extends, __generator, __values } from "tslib"; import { AsyncIterableX } from './asynciterablex.js'; import { returnAsyncIterator } from '../util/returniterator.js'; import { wrapWithAbort } from './operators/withabort.js'; import { throwIfAborted } from '../aborterror.js'; /** @ignore */ var CatchAllAsyncIterable = /** @class */ (function (_super) { __extends(CatchAllAsyncIterable, _super); function CatchAllAsyncIterable(source) { var _this = _super.call(this) || this; _this._source = source; return _this; } CatchAllAsyncIterable.prototype[Symbol.asyncIterator] = function (signal) { return __asyncGenerator(this, arguments, function _a() { var error, hasError, _b, _c, source, it_1, c, _d, done, value, e_1, e_2_1; var e_2, _e; return __generator(this, function (_f) { switch (_f.label) { case 0: throwIfAborted(signal); error = null; hasError = false; _f.label = 1; case 1: _f.trys.push([1, 16, 17, 18]); _b = __values(this._source), _c = _b.next(); _f.label = 2; case 2: if (!!_c.done) return [3 /*break*/, 15]; source = _c.value; it_1 = wrapWithAbort(source, signal)[Symbol.asyncIterator](); error = null; hasError = false; _f.label = 3; case 3: if (!1) return [3 /*break*/, 13]; c = {}; _f.label = 4; case 4: _f.trys.push([4, 8, , 10]); return [4 /*yield*/, __await(it_1.next())]; case 5: _d = _f.sent(), done = _d.done, value = _d.value; if (!done) return [3 /*break*/, 7]; return [4 /*yield*/, __await(returnAsyncIterator(it_1))]; case 6: _f.sent(); return [3 /*break*/, 13]; case 7: c = value; return [3 /*break*/, 10]; case 8: e_1 = _f.sent(); error = e_1; hasError = true; return [4 /*yield*/, __await(returnAsyncIterator(it_1))]; case 9: _f.sent(); return [3 /*break*/, 13]; case 10: return [4 /*yield*/, __await(c)]; case 11: return [4 /*yield*/, _f.sent()]; case 12: _f.sent(); return [3 /*break*/, 3]; case 13: if (!hasError) { return [3 /*break*/, 15]; } _f.label = 14; case 14: _c = _b.next(); return [3 /*break*/, 2]; case 15: return [3 /*break*/, 18]; case 16: e_2_1 = _f.sent(); e_2 = { error: e_2_1 }; return [3 /*break*/, 18]; case 17: try { if (_c && !_c.done && (_e = _b.return)) _e.call(_b); } finally { if (e_2) throw e_2.error; } return [7 /*endfinally*/]; case 18: if (hasError) { throw error; } return [2 /*return*/]; } }); }); }; return CatchAllAsyncIterable; }(AsyncIterableX)); export { CatchAllAsyncIterable }; /** * Continues an async-iterable sequence that is terminated by an exception with the next async-iterable sequence. * * @template T The type of the elements in the source and handler sequences. * @param {Iterable<AsyncIterable<T>>} source async-iterable sequences to catch exceptions for. * @returns {AsyncIterableX<T>} An async-iterable sequence containing elements from consecutive source * sequences until a source sequence terminates successfully. */ export function catchAll(source) { return new CatchAllAsyncIterable(source); } /** * Continues an async-iterable sequence that is terminated by an exception with the next async-iterable sequence. * * @template T The type of the elements in the source and handler sequences. * @param {...AsyncIterable<T>[]} args async-iterable sequences to catch exceptions for. * @returns {AsyncIterableX<T>} An async-iterable sequence containing elements from consecutive source * sequences until a source sequence terminates successfully. */ export function catchError() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } return new CatchAllAsyncIterable(args); } //# sourceMappingURL=catcherror.js.map