Class IntRange

An immutable number range with min/max values.

Remarks

The minimum and maximum values can use null to represent "none".

Hierarchy

  • IntRange

Implements

Constructors

  • Constructor.

    Parameters

    • min: null | number

      the mimnimum value or null for "no minimum"

    • max: null | number

      the maximum value or null for "no maximum"

    Returns IntRange

Properties

#max: null | number
#min: null | number

Accessors

  • get isSingleton(): boolean
  • Test if this range represents a singleton value, where the minimum and maximum values in the range are equal.

    Returns boolean

  • get length(): number
  • Get the number of values between min and max, inclusive.

    Returns number

    Remarks

    This will return +Inf if either min or max is null.

  • get max(): null | number
  • Get the minimum value.

    Returns null | number

  • get min(): null | number
  • Get the minimum value.

    Returns null | number

Methods

  • Compare two range values.

    Parameters

    • l: null | number

      the left value

    • r: null | number

      the right value

    Returns 1 | 0 | -1

    -1, 0, or 1 if l is less than, equal to, or greater than r

  • Test if this range is adjacent to (but not intersecting) a given range.

    Parameters

    • o: IntRange

      the range to compare to this range

    Returns boolean

    true if this range is adjacent to the given range

  • Test if this range could be merged with another range.

    Two ranges can be merged if they are either adjacent to or intersect with each other.

    Parameters

    Returns boolean

    true if this range is either adjacent to or intersects with the given range

  • Compares this object with the specified object for order.

    Unbounded (null) values are ordered before bounded (non-null) values.

    Parameters

    Returns number

    -1, 0, or 1 if this is less than, equal to, or greater than o

  • Test if a value is within this range, inclusive.

    Parameters

    • value: null | number

      the value to test (null represents infinity)

    Returns boolean

    true if min <= value <= max

  • Test if another range is completely within this range, inclusive.

    Parameters

    • min: null | number

      the minimum of the range to test

    • max: null | number

      the maximum of the range to test

    Returns boolean

    true if this.min <= min <= max <= this.max

  • Test if another range is completely within this range, inclusive.

    Parameters

    Returns boolean

    true if this.min <= o.min <= o.max <= this.max

  • Test for equality.

    This method tests if obj is an instance of IntRange and compares the min and max values for strict equality.

    Parameters

    • obj: any

      the object to compare to

    Returns boolean

    true if obj is equal to this

  • Test if this range intersects with a given range.

    Parameters

    • o: IntRange

      the range to compare to this range

    Returns boolean

    true if this range intersects (overlaps) with the given range

  • Merge this range with a given range, returning the merged range.

    Parameters

    • o: IntRange

      the range to merge with this range

    Returns IntRange

    the new merged range

  • Get a string representation.

    The format returned by this method is [min..max]. Any null value will be represented as an empty string.

    Returns string

    the string representation

  • Get a locale-specific range delimiter to use.

    Parameters

    • Optional locale: string

      the locale of the delimiter to get; defaults to the runtime locale if not provided

    Returns string

    the default range delimiter for the given locale

  • Generate a description of a range.

    Parameters

    Returns string

    if r represents "all possible values" then the literal string *, otherwise the string representation of r

    Remarks

    This method is similar to toString(), except that it compares a given range with a bounding range. If the given range is equal to the bounding range, or the given range is undefined, then the given range is taken to mean "all possible values" and a * character is returned instead of the normal [min..max] representation.

  • Create a singleton range, where the minimum and maximum values are equal.

    Parameters

    • value: null | number

      the minimum and maximum value

    Returns IntRange

    the new singleton range instance

  • Parse a range array of number strings into an IntRange.

    Parameters

    • value: undefined | string | string[]

      the range to parse; can be a string adhering to splitRange() or an array with 1 or 2 number value elements, or * to represent "none"

    • Optional bounds: IntRange

      the optional bounds (inclusive) to enforce; if the parsed range

    • Optional options: IntRangeFormatOptions

      options to control the formatting

    Returns undefined | IntRange

    the parsed range, or undefined if a range could not be parsed or extends beyond the given bounds then undefined will be returned

  • Create a range.

    Parameters

    • min: null | number

      the minimum value

    • max: null | number

      the maximum value

    Returns IntRange

    the new range instance

Generated using TypeDoc