UNPKG

980 BJavaScriptView Raw
1import { AsyncIterableX } from './asynciterablex';
2import { throwIfAborted } from '../aborterror';
3class 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 * Generates an async-iterable sequence of integral numbers within a specified range.
18 *
19 * @export
20 * @param {number} start The value of the first integer in the sequence.
21 * @param {number} count The number of sequential integers to generate.
22 * @returns {AsyncIterableX<number>} An async-iterable sequence that contains a range of sequential integral numbers.
23 */
24export function range(start, count) {
25 return new RangeAsyncIterable(start, count);
26}
27
28//# sourceMappingURL=range.mjs.map