Dreamdata Shared Utils & Constants - v1.19.0
    Preparing search index...

    Class NumberUtils

    Index

    Constructors

    Methods

    • Clamps a number between a minimum and maximum value.

      Parameters

      • value: number

        The value to clamp.

      • min: number

        The minimum allowed value.

      • max: number

        The maximum allowed value.

      Returns number

      The clamped value.

    • Formats metric values according to the framework rules:

      • Numbers under 10: 2 decimals
      • Numbers under 100 but over 10: 1 decimal
      • Numbers 100 and over: 0 decimals
      • Abbreviate thousands, millions, billions, trillions with K, M, B, T

      Parameters

      • value: number

        The number to format.

      • displayFormat: "decimal" | "integer" | null

        The display format type.

      • displaySymbol: "percent" | "currency" | "none" | null | undefined

        The display symbol.

      Returns string

      The formatted number string.

    • Formats a number with display format and symbols.

      Parameters

      • number: number

        The number to format.

      • displayFormat: "decimal" | "integer" | null

        The display format type.

      • displaySymbol: DisplaySymbol

        The display symbol (percent, currency, none).

      • Optionalcurrency: string

        Currency symbol (default: "$").

      Returns string

      The formatted number string.

    • Formats values for table display with proper separators and display symbols. Adds thousands separators (commas) for readability and display symbols if specified. Does NOT modify decimal places (preserves original precision). Does NOT abbreviate large numbers (no K, M, B, T suffixes).

      Parameters

      • value: number

        The number to format.

      • displaySymbol: "percent" | "currency" | "none" | null | undefined

        The display symbol.

      Returns string

      The formatted number string.

    • Formats a number with thousands suffixes (k, m, b, t).

      Parameters

      • number: number

        The number to format.

      • decimals: number = 0

        Number of decimal places to show (default: 0).

      Returns string

      The formatted number with suffix.

    • Generates an array of numbers from given start and end point

      Parameters

      • start: number
      • end: number
      • count: number

      Returns number[]

    • Formats a number for display with specified decimal digits.

      Parameters

      • value: number

        The number to format.

      • options: IToDisplayValueProps = {}

        Formatting options.

        • decimalDigits

          Number of decimal places to show (default: 0).

      Returns string

      The formatted number string.