1.6.3 • Published 1 year ago

format-money-js v1.6.3

Weekly downloads
66
License
BSD-2-Clause
Repository
github
Last release
1 year ago

format-money-js

Build Status version download per month

Zero dependency tiny JavaScript library (841 bytes) by CurrencyRate.today, providing simple way and advanced number, money and currency formatting and removes all formatting/cruft and returns the raw float value. Size of library: 841 bytes in zip and 1.2 kByte in min formats.

Functions

from: money and currency formatting;

un: removes all formatting/cruft and returns the raw float value.

Examples

const { FormatMoney } = require('format-money-js');

const fm = new FormatMoney({
  decimals: 2
});

console.log(fm.from(12345.67, { symbol: '$' })); // return string: $12,345.67
console.log(fm.un('€12,345;67')); // return number: 12345.67
const { FormatMoney } = require('format-money-js');

const fm = new FormatMoney({
  decimals: 2
});

console.log(fm.from(
  12345.67, 
  { symbol: '$' },
  true // Parse, return object
  )
);
/* return object: 
{
  source: 12345.67,
  negative: false,
  fullAmount: '12,345.67',
  amount: '12,345',
  decimals: '.67',
  symbol: '$'
}*/

Options

You can added options in construct of class and in method. But method will be primary.

Example:

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

console.log(fm.from(12345.67, { symbol: '€' })); // €12,345.67
console.log(fm.un('€12.345,67', { decimalPoint: ',' })); // 12345.67
NameDefaultTypeExample
groupingtrueBoolean1,000 (true) vs 1000 (false)
separator,String1,000
decimalPoint.String1,234.56
decimals0Number1,234 (0 - without decimals)
symbolNoneString$1,234.56 (if append false)
appendfalseString1,234.56$ (if append true)
leadZerostrueBooleantrue - 1.10, false - 1.1 (leading zeros)

Source

https://currencyrate.today/

https://fx-w.io/

https://moneyconvert.net/

https://cr.today/

1.6.3

1 year ago

1.6.2

1 year ago

1.6.1

1 year ago

1.6.0

1 year ago

1.5.5

2 years ago

1.5.3

2 years ago

1.4.4

2 years ago

1.5.2

2 years ago

1.5.1

2 years ago

1.5.0

2 years ago

1.4.3

3 years ago

1.4.0

3 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago