ix
Version:
The Interactive Extensions for JavaScript
31 lines (29 loc) • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.throwError = void 0;
const tslib_1 = require("tslib");
const asynciterablex_js_1 = require("./asynciterablex.js");
const aborterror_js_1 = require("../aborterror.js");
class ThrowAsyncIterable extends asynciterablex_js_1.AsyncIterableX {
constructor(error) {
super();
this._error = error;
}
[Symbol.asyncIterator](signal) {
return tslib_1.__asyncGenerator(this, arguments, function* _a() {
(0, aborterror_js_1.throwIfAborted)(signal);
throw this._error;
});
}
}
/**
* 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.
*/
function throwError(error) {
return new ThrowAsyncIterable(error);
}
exports.throwError = throwError;
//# sourceMappingURL=throwerror.js.map