Currency Formatter
A simple Javascript utility that helps you to display currency properly
Install
npm install currency-formatter --save
Basic Usage
var currencyFormatter = require('currency-formatter');
currencyFormatter.format(1000000, { code: 'USD' });
currencyFormatter.format(1000000, { code: 'GBP' });
currencyFormatter.format(1000000, { code: 'EUR' });
You can also get the currency information.
var currencyFormatter = require('currency-formatter');
currencyFormatter.findCurrency('USD');
Advanced Usage
Currency Formatter uses accounting library under the hood, and you can use its options to override the default behavior.
var currencyFormatter = require('currency-formatter');
currencyFormatter.format(1000000, {
symbol: '@',
decimal: '*',
thousand: '^',
precision: 1,
format: '%v %s'
});
You could also get a list of all the currencies here using one of the following:
var currencies = require('currency-formatter/currencies');
var currencyFormatter = require('currency-formatter');
var currencies = currencyFormatter.currencies;
License
MIT