Argon Formatter
Argon Formatter is universal currency formatter. This is a fork of Smirzaei's currency-formatter except that it provides UMD and ESM builds.
Install
npm install argon-formatter --save
Basic Usage
Using currency code
; argonFormatter;// => '$1,000,000.00' argonFormatter;// => '£1,000,000.00' argonFormatter;// => '1 000 000,00 €'
Using locale
; argonFormatter;// => '$1,000,000.00' argonFormatter;// => '£1,000,000.00' argonFormatter;// => '£1,000,000.00' argonFormatter;// => '1.000.000,00 €' argonFormatter;// => '€1.000.000,00'
Get currency information
; argonFormatter;// returns:// {// code: 'USD',// symbol: '$',// thousandsSeparator: ',',// decimalSeparator: '.',// symbolOnLeft: true,// spaceBetweenAmountAndSymbol: false,// decimalDigits: 2// }
Unformat
argonFormatter// => 10.5 argonFormatter// => 1000000 argonFormatter// => 10.5 argonFormatter// => 1000000 argonFormatter// => 1000.99 argonFormatter// => 10000 argonFormatter// => 10 argonFormatter// => 1000
Advanced Usage
Argon Formatter uses accounting under the hood, and you can use its options to override default behavior.
;argonFormatter; // => '1^000^000*0 @' // Different formatting for positive and negative valuesargonFormatter; // => ($10)
Getting a list of all currencies
const currencies = argonFormatter;