UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

25 lines (23 loc) 718 B
import { AsyncIterableX } from './asynciterablex.js'; import { throwIfAborted } from '../aborterror.js'; class ThrowAsyncIterable extends AsyncIterableX { _error; constructor(error) { super(); this._error = error; } async *[Symbol.asyncIterator](signal) { 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. */ export function throwError(error) { return new ThrowAsyncIterable(error); } //# sourceMappingURL=throwerror.js.map