@reactivex/ix-es5-esm
Version:
The Interactive Extensions for JavaScript
32 lines (30 loc) • 1.15 kB
JavaScript
import { __asyncGenerator, __await, __extends, __generator } from "tslib";
import { AsyncIterableX } from './asynciterablex.js';
import { throwIfAborted } from '../aborterror.js';
var ThrowAsyncIterable = /** @class */ (function (_super) {
__extends(ThrowAsyncIterable, _super);
function ThrowAsyncIterable(error) {
var _this = _super.call(this) || this;
_this._error = error;
return _this;
}
ThrowAsyncIterable.prototype[Symbol.asyncIterator] = function (signal) {
return __asyncGenerator(this, arguments, function _a() {
return __generator(this, function (_b) {
throwIfAborted(signal);
throw this._error;
});
});
};
return ThrowAsyncIterable;
}(AsyncIterableX));
/**
* Creates an async-iterable that throws the specified error upon iterating.
*
* @param {*} error The error to throw upon iterating the async-iterable.
* @returns {AsyncIterableX<never>} An async-iterable that throws when iterated.
*/
export function throwError(error) {
return new ThrowAsyncIterable(error);
}
//# sourceMappingURL=throwerror.js.map