@sensimods/utility-lab
    Preparing search index...

    Function formatCurrency

    • Formats a number as a localized currency string. Utilizes the built-in Intl.NumberFormat API for robust internationalization support. Falls back to a default format if the provided locale or currency code is invalid.

      Parameters

      • amount: number

        The numeric amount to format as currency.

      • currency: string = "USD"

        The ISO 4217 currency code (e.g., "USD", "EUR"). Defaults to "USD".

      • locale: string = "en-US"

        The BCP 47 language tag for locale formatting (e.g., "en-US", "de-DE"). Defaults to "en-US".

      Returns string

      A string representing the formatted currency amount.

      Will throw a TypeError if the amount is not a finite number.

      formatCurrency(1250.5)
      // "$1,250.50"
      formatCurrency(100, "EUR", "de-DE")
      // "100,00 €"