The numeric value to format
Formatting options
When true, omits the R$ currency symbol (default: false)
Number of decimal places to display (default: 2)
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'
Formats a number as a Brazilian Real (BRL) currency string.
Uses
Intl.NumberFormatwith thept-BRlocale to produce a properly formatted currency value, with optional control over the currency symbol and fraction digits.