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
    start
    number | Index

    The start of the interval (inclusive).

    end
    number | Index

    The end of the interval (exclusive).

    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
    Interval

    end

    Gets an Index that represents the end of the interval (exclusive).

    Declaration
    get end(): Index;
    Property Value
    Index

    start

    Gets an Index that represents the start of the interval (inclusive).

    Declaration
    get start(): Index;
    Property Value
    Index

    step

    Gets the number of elements to advance when stepping through an indexed collection.

    Declaration
    get step(): number;
    Property Value
    number

    Methods

    [Equatable.equals](other)

    Declaration
    [Equatable.equals](other: unknown): boolean;
    Parameters
    other
    unknown

    Returns
    boolean

    [Equatable.hash]()

    Declaration
    [Equatable.hash](): number;
    Returns
    number

    [Symbol.iterator]()

    Declaration
    [Symbol.iterator](): Generator<number, void, unknown>;
    Returns
    Generator<number, void, unknown>

    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
    Interval

    equals(other)

    Declaration
    equals(other: Interval): boolean;
    Parameters
    other
    Interval

    Returns
    boolean

    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
    [number, number, number]

    A tuple of [start, end, step].

    hash()

    Declaration
    hash(): number;
    Returns
    number

    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
    Interval

    toString()

    Declaration
    toString(): string;
    Returns
    string

    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
    Generator<number, void, unknown>

    Generated by DocFX