Ultra Small Currency Fomatting Library – format-money-js

Category: Javascript | January 27, 2021
Author: dejurin
Views Total: 209 views
Official Page: Go to website
Last Update: January 27, 2021
License: BSD-2-Clause

Preview:

Ultra Small Currency Fomatting Library – format-money-js

Description:

format-money-js is an ultra-light (~600 bytes) and standalone currency formatting JavaScript library for the web.

Comes with a number of formatting options to output currency values in a customized way.

How to use it:

1. Download and import the format-money-js library into the document.

<script src="dist/format-money.js"></script>

2. Format a currency value you provide.

const fm = new FormatMoney();
fm.from(12345.67, { 
  symbol: '$' 
}) // => $12,345,67

3. Customize the number of decimal places. Default 0.

const fm = new FormatMoney({ 
      symbol: '$' ,
      decimals: 2
});

4. Customize the string that separates the thousands of the currency value.

const fm = new FormatMoney({ 
      symbol: '$' ,
      separator: ','
});

5. Customize the string that separates the integer and the fraction parts of the currency value.

const fm = new FormatMoney({ 
      symbol: '$' ,
      decimalPoint: '.'
});

6. Enable/disable the thousands delimiter. Default: true.

const fm = new FormatMoney({ 
      symbol: '$' ,
      grouping: false // => 1234
});

7. Append the currency symbol to the end of the formatted value.

const fm = new FormatMoney({ 
      symbol: '$' ,
      append: true // => 12,345,67$
});

Changelog:

v1.4.3 (01/27/2021)

  • Updated JS

v1.3.3 (11/01/2020)

  • Updated JS

You Might Be Interested In:


Leave a Reply