1 | import { IterableX } from './iterablex';
|
2 | class ThrowIterable extends IterableX {
|
3 | constructor(error) {
|
4 | super();
|
5 | this._error = error;
|
6 | }
|
7 | *[Symbol.iterator]() {
|
8 | throw this._error;
|
9 | }
|
10 | }
|
11 | /**
|
12 | * Creates an async-iterable that throws the specified error upon iterating.
|
13 | *
|
14 | * @export
|
15 | * @param {*} error The error to throw upon iterating the iterable.
|
16 | * @returns {AsyncIterableX<never>} An iterable that throws when iterated.
|
17 | */
|
18 | export function throwError(error) {
|
19 | return new ThrowIterable(error);
|
20 | }
|
21 |
|
22 | //# sourceMappingURL=throwerror.mjs.map
|