ix
Version:
The Interactive Extensions for JavaScript
31 lines (29 loc) • 1.13 kB
JavaScript
import { __asyncGenerator, __await } from "tslib";
import { AsyncIterableX } from './asynciterablex.mjs';
import { throwIfAborted } from '../aborterror.mjs';
class RangeAsyncIterable extends AsyncIterableX {
constructor(start, count) {
super();
this._start = start;
this._count = count;
}
[Symbol.asyncIterator](signal) {
return __asyncGenerator(this, arguments, function* _a() {
throwIfAborted(signal);
for (let current = this._start, end = this._start + this._count; current < end; current++) {
yield yield __await(current);
}
});
}
}
/**
* Generates an async-iterable sequence of integral numbers within a specified range.
*
* @param {number} start The value of the first integer in the sequence.
* @param {number} count The number of sequential integers to generate.
* @returns {AsyncIterableX<number>} An async-iterable sequence that contains a range of sequential integral numbers.
*/
export function range(start, count) {
return new RangeAsyncIterable(start, count);
}
//# sourceMappingURL=range.mjs.map