Interval Class
Package: @esfx/interval
Represents an interval within an indexed collection.
Declaration
export declare class Interval
Constructors
constructor(start, end, step)
Creates a new Interval
.
Declaration
constructor(start: number | Index, end: number | Index, step?: number);
Parameters
- step
- number
The number of elements to advance when stepping through an indexed collection (default: 1
).
Properties
all
Gets an Interval
that represents every element of a collection.
Declaration
static get all(): Interval;
Property Value
end
Gets an Index
that represents the end of the interval (exclusive).
Declaration
get end(): Index;
Property Value
start
Gets an Index
that represents the start of the interval (inclusive).
Declaration
get start(): Index;
Property Value
step
Gets the number of elements to advance when stepping through an indexed collection.
Declaration
get step(): number;
Property Value
Methods
[Equatable.equals](other)
Declaration
[Equatable.equals](other: unknown): boolean;
Parameters
- other
- unknown
Returns
[Equatable.hash]()
Declaration
[Equatable.hash](): number;
Returns
[Symbol.iterator]()
Declaration
[Symbol.iterator](): Generator<number, void, unknown>;
Returns
endAt(index)
Creates a new Interval
between the specified index (exclusive) and the start of the indexed collection.
Declaration
static endAt(index: number | Index): Interval;
Parameters
- index
- number | Index
Returns
equals(other)
Declaration
equals(other: Interval): boolean;
Parameters
- other
- Interval
Returns
getIndices(length)
Calculates the start and end offsets given the length of an indexed collection.
Declaration
getIndices(length: number): [number, number, number];
Parameters
- length
- number
Returns
A tuple of [start, end, step]
.
hash()
Declaration
hash(): number;
Returns
startAt(index)
Creates a new Interval
between the specified index (inclusive) and the end of the indexed collection.
Declaration
static startAt(index: number | Index): Interval;
Parameters
- index
- number | Index
Returns
toString()
Declaration
toString(): string;
Returns
values(length)
Yields each offset within the interval given the length of an indexed collection.
Declaration
values(length?: number): Generator<number, void, unknown>;
Parameters
- length
- number
Returns