iteragain
Version:
Javascript Iterable/Iterator/Generator-function utilities.
38 lines • 1.59 kB
TypeScript
/**
* A class for representing a range of numbers and also iterating through them. When `next.done` is true, resets the
* internal counter back to `start`.
*/
export declare class RangeIterator implements IterableIterator<number> {
/** The start of this range of numbers (inclusive). */
readonly start: number;
/** The stop/end point of this range of numbers (exclusive). */
readonly stop: number;
/** Each iteration is increased by this amount. */
readonly step: number;
/** Alias of `includes`. */
has: (n: number) => boolean;
/** Alias of `nth`. */
at: (index: number) => number | undefined;
protected i: number;
protected _length: number;
/** The sign of `step`. */
protected readonly stepSign: number;
constructor(...params: number[]);
/** The length of this range of numbers. */
get length(): number;
[Symbol.iterator](): IterableIterator<number>;
next(): IteratorResult<number>;
/** Returns true if `n` is inside of this range. */
includes(n: number): boolean;
/** Returns the number at `index` in this range. `index` can be negative to access indices starting from the end. */
nth(index: number): number | undefined;
/** Returns the index that `n` is at in this range. */
index(n: number): number;
/** Returns true if this range is equal to another. */
equal(other: RangeIterator): boolean;
toString(): string;
/** Iterates and collects all values into an Array. */
toArray(): number[];
}
export default RangeIterator;
//# sourceMappingURL=RangeIterator.d.ts.map