Options
All
  • Public
  • Public/Protected
  • All
Menu

Defines a number range with numeric min, max

Hierarchy

  • NumberRange

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new NumberRange(min?: number, max?: number): NumberRange
  • Parameters

    • Default value min: number = 0
    • Default value max: number = 10

    Returns NumberRange

Properties

Readonly max

max: number

Readonly min

min: number

Accessors

diff

  • get diff(): number
  • Returns a difference between max and min

    Returns number

Methods

clip

  • Clips a range to a min, max value

    remarks

    E.g. if the current range is [1,5] and input is [2,6] then result will be [2,5]

    Parameters

    Returns NumberRange

    The new clipped range

equals

  • Returns true if the range equals another by value

    Parameters

    Returns boolean

growBy

  • Grows a range by a min and max factor

    remarks

    If the current range is [5,10] and the input range is [0.1, 0.1] the current range will be grown by 10%, so [4.5, 10.5]

    Parameters

    • range: NumberRange

      The grow factor

    • Default value isLogarithmic: boolean = false

      When true, treats the growth factor as logarithmic not linear

    Returns NumberRange

isDefined

  • isDefined(): boolean
  • Returns true if the range is defined (is a real number, not NaN, not infinite, and not undefined)

    Returns boolean

isZero

  • isZero(): boolean
  • Returns true if the range min === range max

    Returns boolean

toString

  • toString(): string
  • Returns a string representation of a NumberRange for easy debugging

    Returns string

union

  • Returns a new NumberRange which is the union of two ranges

    remarks

    E.g. if current range is [1,2] and input is [2,3] the result range will be [1,3]

    Parameters

    Returns NumberRange

    the new union range

Generated using TypeDoc