@consumidor-positivo/ts-utils - v1.21.0
    Preparing search index...

    Function formatCurrency

    • Formats a number as a Brazilian Real (BRL) currency string.

      Uses Intl.NumberFormat with the pt-BR locale to produce a properly formatted currency value, with optional control over the currency symbol and fraction digits.

      Parameters

      • value: number

        The numeric value to format

      • options: FormatCurrencyOptions = {}

        Formatting options

        • hideMoneySymbol

          When true, omits the R$ currency symbol (default: false)

        • fractionDigits

          Number of decimal places to display (default: 2)

      Returns string

      The formatted currency string

      import { formatCurrency } from '@consumidor-positivo/ts-utils';

      // Default usage
      formatCurrency(1234.5); // 'R$ 1.234,50'

      // Hiding the currency symbol
      formatCurrency(1234.5, { hideMoneySymbol: true }); // '1.234,50'

      // Custom fraction digits
      formatCurrency(1234.5, { fractionDigits: 0 }); // 'R$ 1.235'