amount

Amount and currency formatter

Usage no npm install needed!

<script type="module">
  import amount from 'https://cdn.skypack.dev/amount';
</script>

README

amount

Amount and currency formatter

npm Build Status GitHub license

node

npm i amount --save

yarn

yarn add amount

Usage

// amount(amount, decimals_separator, thousands_separator, decimal_digits)

amount(87686.987);
// '87686.987'

// setting decimals separator

amount(87686.987, ',');
// '87686,987'

// setting thousands separator

amount(87686.987, ',', '.');
// '87.686,987'

// setting number of decimals

amount(87686.987, ',', '.', 2);
// '87.686,98'

amount(87686.987, ',', '.', 1);
// '87.686,9'

amount(87686, ',', '.', 2);
// '87.686,00'

currency


amount.currency(87686.987, 'EUR');
// '87 686,98 €'

amount.currency(87686.987, 'USD');
// '$87,686.98'

amount.currency(87686.987, {
  thousands_separator: ',',
  decimals_separator: '.',
  decimal_digits: 2,
  symbol: '€',
  symbol_on_left: false,
  symbol_space: ' ',
});
// '87.686,98 €'