Socket
Socket
Sign inDemoInstall

format-money-js

Package Overview
Dependencies
104
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    format-money-js

Zero dependency tiny JavaScript library (1kB 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.


Version published
Maintainers
1
Created

Readme

Source

format-money-js

Build Status version download per month

Zero dependency tiny JavaScript library (1kB 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.

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/

Keywords

FAQs

Last updated on 29 Sep 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc