RangeListObject

The RangeListObject represents a RangeList of values and can be used to inspect a RangeList property without having to manually parse strings. A new RangeListObject can also be constructed to return from a derived property of the appropriate data type.

Constructor Example

var x = new RangeListObject();
var y = new RangeListObject("1-10,20-25");
var z = new RangeListObject([{start:1, end:10},{start:20, end:25}]);

Table 28. RangeListObject Constructor Parameters

Parameters

Optional

Description

ranges

True

Range values for initialization. This parameter is optional. Two formats are accepted:

  • Array––An array where each element of the array is an object that has a start and end property indicating the range. Any object in the array that does not have these properties is ignored.

  • String––A comma-separated list of string entries. Each entry contains the start and end values separated by a dash (-) or equals (=) symbol.

Table 29. RangeListObject Properties

Name

Description

Ranges

An Array of objects. Each object has two properties:

  • start––The start of the range entry

  • end––The end of the range entry

This property is read-only. To modify the range use the methods below.

Table 30. RangeListObject Methods

Name

Description

AddRange(start, end)

Adds a new range to the range list. This may expand an existing range entry or create a new one. To add a single number to the list, use it for both the start and end parameters. Both parameters will be coerced to integers if necessary.

Contains(value)

Returns True if the value is in the range list, otherwise False.

value will be coerced to an integer if necessary.

IsSupersetOf(range)

Returns True if the current RangeListObject is a superset of the given RangeListObject. Passing another type of object is an error.

RemoveRange(start, end)

Removes a range from the list. This removal may split an existing range entry into two or remove an entry entirely. To remove a single number from the list use it for both the start and end parameters. Both parameters will be coerced to integers if necessary.