An Interval represents a subset of a string.

interface Interval {
    contents: string;
    endIdx: number;
    sourceString: string;
    startIdx: number;
    collapsedLeft(): Interval;
    collapsedRight(): Interval;
    coverageWith(...intervals): Interval;
    getLineAndColumn(): LineAndColumnInfo;
    getLineAndColumnMessage(): string;
    minus(that): Interval[];
    relativeTo(that): Interval;
    subInterval(offset, len): Interval;
    trimmed(): Interval;
}

Properties

contents: string

Contents of interval

endIdx: number

The end index of the interval in sourceString.

sourceString: string

The string containing the interval.

startIdx: number

The start index of the interval in sourceString.

Methods

  • Returns a new Interval at the start of this one

    Returns Interval

  • Returns a new Interval at the end of this one

    Returns Interval

  • Returns a new Interval that covers this Interval and all the argument Intervals. The new Interval will start at the lowest start index and end at the largest end index.

    Parameters

    Returns Interval

  • Returns a structure containing information about the location of the interval in the source string, including the line and column number.

    Returns LineAndColumnInfo

  • Returns a nicely-formatted string describing the start of the Interval.

    Returns string

  • Returns an array of 0, 1, or 2 intervals that represents the result of the interval difference operation.

    Parameters

    Returns Interval[]

  • Returns a new Interval that has the same extent as this one, but which is relative to that, an Interval that fully covers this one.

    Parameters

    Returns Interval

  • Returns a new Interval on the same source string, with the given length and beginning at startIdx + offset.

    Parameters

    • offset: number
    • len: number

    Returns Interval

  • Returns a new Interval which contains the same contents as this one, but with whitespace trimmed from both ends.

    Returns Interval

Generated using TypeDoc