Class Number

Index

Methods

Methods

public static constrain(number?: number, min?: number, max?: number): number

[Method] Checks whether or not the passed number is within a desired range

Parameters

  • number?: number optional

    Number The number to check

  • min?: number optional

    Number The minimum number in the range

  • max?: number optional

    Number The maximum number in the range

Returns

number

Number The constrained value if outside the range, otherwise the current value

public static from(value?: any, defaultValue?: number): number

[Method] Validate that a value is numeric and convert it to a number if necessary

Parameters

  • value?: any optional

    Object

  • defaultValue?: number optional

    Number The value to return if the original value is non-numeric

Returns

number

Number value, if numeric, defaultValue otherwise

public static snap(value?: number, increment?: number, minValue?: number, maxValue?: number): number

[Method] Snaps the passed number between stopping points based upon a passed increment value

Parameters

  • value?: number optional

    Number The unsnapped value.

  • increment?: number optional

    Number The increment by which the value must move.

  • minValue?: number optional

    Number The minimum value to which the returned value must be constrained. Overrides the increment..

  • maxValue?: number optional

    Number The maximum value to which the returned value must be constrained. Overrides the increment..

Returns

number

Number The value of the nearest snap target.

public static toFixed(value?: number, precision?: number)

[Method] Formats a number using fixed point notation

Parameters

  • value?: number optional

    Number The number to format

  • precision?: number optional

    Number The number of digits to show after the decimal point