Options
All
  • Public
  • Public/Protected
  • All
Menu

Module number

Functions

assertIsInteger

  • assertIsInteger(value: any): void | never
  • Asserts that value is an integer.

    throws

    {Exception} When value is not an integer.

    Parameters

    • value: any

      Value to check.

    Returns void | never

assertIsPercentage

  • assertIsPercentage(num: number): void | never
  • Asserts that num represents a percentage and has a value in the [0,1] interval.

    throws

    {Exception} When num is not a percentage.

    Parameters

    • num: number

      Number to test.

    Returns void | never

convertFrom

  • convertFrom(value: boolean | number | string | null | undefined, strictNullables?: boolean): number | null | undefined
  • Converts a giver value to it's corresponding number.

    Parameters

    • value: boolean | number | string | null | undefined

      Number like value.

    • Optional strictNullables: boolean

      How to thread nullable values. When enabled, given undefined or null will throw an error When disabled, given undefined or null will return them back.

    Returns number | null | undefined

    Converted value to number.

integerPercentage

  • integerPercentage(number: number, percent: Percentage): number
  • Calculates percentage from a number as an integer.
    Integer is obtained by using {@link Math.round}.

    Parameters

    • number: number

      Number.

    • percent: Percentage

      Percent from that number.

    Returns number

    Integer number which represents percent from number.

percentage

  • percentage(number: number, percent: Percentage): number
  • Calculates percentage from a number.

    Parameters

    • number: number

      Number.

    • percent: Percentage

      Percent from that number.

    Returns number

    Number which represents percent from number.

random

  • random(min: number, max: number): number
  • Returns a random number between min (inclusive) and max (exclusive)

    Parameters

    • min: number

      Minimum value.

    • max: number

      Maximum value.

    Returns number

    Random number.

randomInt

  • randomInt(min: number, max: number): number
  • Returns a random integer between min (inclusive) and max (inclusive). The value is no lower than min (or the next integer greater than min if min isn't an integer) and no greater than max (or the next integer lower than max if max isn't an integer).

    Parameters

    • min: number

      Minimum value.

    • max: number

      Maximum value.

    Returns number

    Random integer.

toLetter

  • toLetter(nr: number): string
  • Transform a number to a string by using only base58 chars.

    Parameters

    • nr: number

      Number to convert.

    Returns string

    The string-representation of the number.