1 | import { AsyncIterableX } from './asynciterablex';
|
2 | import { throwIfAborted } from '../aborterror';
|
3 | class RangeAsyncIterable extends AsyncIterableX {
|
4 | constructor(start, count) {
|
5 | super();
|
6 | this._start = start;
|
7 | this._count = count;
|
8 | }
|
9 | async *[Symbol.asyncIterator](signal) {
|
10 | throwIfAborted(signal);
|
11 | for (let current = this._start, end = this._start + this._count; current < end; current++) {
|
12 | yield current;
|
13 | }
|
14 | }
|
15 | }
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | export function range(start, count) {
|
25 | return new RangeAsyncIterable(start, count);
|
26 | }
|
27 |
|
28 |
|