UNPKG

@reactivex/ix-esnext-esm

Version:

The Interactive Extensions for JavaScript

29 lines (27 loc) 980 B
import { AsyncIterableX } from './asynciterablex'; import { throwIfAborted } from '../aborterror'; class RangeAsyncIterable extends AsyncIterableX { constructor(start, count) { super(); this._start = start; this._count = count; } async *[Symbol.asyncIterator](signal) { throwIfAborted(signal); for (let current = this._start, end = this._start + this._count; current < end; current++) { yield current; } } } /** * Generates an async-iterable sequence of integral numbers within a specified range. * * @export * @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