Class: Range

Range(locationopt, lengthopt)

A class representing a half-open interval of characters. A range's location property and max() value can be used as arguments for the substring() method to extract a range of characters.

Constructor

new Range(locationopt, lengthopt)

Parameters:
Name Type Attributes Default Description
location number <optional>
-1

Starting index of the range.

length number <optional>
0

Number of characters in the range.

Source:

Classes

Range

Members

length :number

Number of characters in the range.

Type:
  • number
Source:

location :number

Starting index of the range.

Type:
  • number
Source:

Methods

isValid() → {boolean}

Returns whether the range contains a location >= 0.

Source:
Returns:
Type
boolean

max(valueopt) → {number}

Sets the end index of the range, which indicates the character immediately after the last one in the range.

Parameters:
Name Type Attributes Description
value number <optional>

End of the range.

Source:
Returns:
Type
number

toArray() → {RangeTuple}

Returns an array of the range's start and end indexes.

Source:
Returns:
Type
RangeTuple

toString() → {string}

Returns a string representation of the range's open interval.

Source:
Returns:
Type
string