Socket
Socket
Sign inDemoInstall

format-money-js

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

format-money-js - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

2

dist/format-money.d.ts
/*!
* format-money-js v1.1.2
* format-money-js v1.1.4
* (c) 2020 Yurii Derevych

@@ -4,0 +4,0 @@ * Released under the BSD-2-Clause License.

"use strict";
/*!
* format-money-js v1.1.2
* format-money-js v1.1.4
* (c) 2020 Yurii Derevych

@@ -11,3 +11,3 @@ * Released under the BSD-2-Clause License.

this.options = options;
this.version = '1.1.2';
this.version = '1.1.4';
this.defaults = {

@@ -14,0 +14,0 @@ grouping: true,

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class FormatMoney{constructor(t){this.options=t,this.version="1.1.2",this.defaults={grouping:!0,separator:",",decimalPoint:".",decimals:0,prefix:"",suffix:""},this.from=((t,s)=>{s=Object.assign(Object.assign({},this.options),s);const e=t<0?"-":"";let i,o,r,a,n;if(i=Math.abs(t).toFixed(s.decimals),r=(o=(i+="").split("."))[0],a=o.length>1?s.decimalPoint+o[1]:"",s.grouping){n="";for(let t=0,e=r.length;t<e;++t)0!==t&&t%3==0&&(n=s.separator+n),n=r[e-t-1]+n;r=n}return e+s.prefix+r+a+s.suffix}),this.options=Object.assign(Object.assign({},this.defaults),t)}}exports.FormatMoney=FormatMoney;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});class FormatMoney{constructor(t){this.options=t,this.version="1.1.4",this.defaults={grouping:!0,separator:",",decimalPoint:".",decimals:0,prefix:"",suffix:""},this.from=((t,s)=>{s=Object.assign(Object.assign({},this.options),s);const e=t<0?"-":"";let i,o,r,a,n;if(i=Math.abs(t).toFixed(s.decimals),r=(o=(i+="").split("."))[0],a=o.length>1?s.decimalPoint+o[1]:"",s.grouping){n="";for(let t=0,e=r.length;t<e;++t)0!==t&&t%3==0&&(n=s.separator+n),n=r[e-t-1]+n;r=n}return e+s.prefix+r+a+s.suffix}),this.options=Object.assign(Object.assign({},this.defaults),t)}}exports.FormatMoney=FormatMoney;
const { FormatMoney } = require('./dist/format-money.js');
const fm = new FormatMoney({
const fm1 = new FormatMoney({
decimals: 2
});
console.log(fm.from(12345.67, { prefix: '$' })); // $12,345.67
console.log(fm1.from(12345.67, { prefix: '$' })); // $12,345.67
//
const fm2 = new FormatMoney({ prefix: '$' });
console.log(fm2.from(12345.67, { prefix: '€' })); // €12,345.67
{
"name": "format-money-js",
"description": "Tiny JavaScript library (656 bytes) by CurrencyRate.today, providing simple and advanced number, money and currency formatting.",
"version": "1.1.3",
"version": "1.1.4",
"license": "BSD-2-Clause",

@@ -6,0 +6,0 @@ "main": "./dist/format-money.js",

@@ -20,1 +20,20 @@ # format-money-js

```
## Options
You can added options in construct of class and in method. But method will be primary.
### Example:
```
const fm = new FormatMoney({ prefix: '$' });
console.log(fm.from(12345.67, { prefix: '€' })); // €12,345.67
```
| Name | Default | Type | Example
|---------------|----------|---------|------------------------------|
| grouping | true | Boolean | 1,000 (true) vs 1000 (false) |
| separator | , | String | 1,000 |
| decimalPoint | . | String | 1,234.56 |
| decimals | 0 | Number | 1,234 (0 - without decimals) |
| prefix | None | String | $1,234.56 (before) |
| suffix | None | String | 1,234.56$ (after) |
/*!
* format-money-js v1.1.3
* format-money-js v1.1.4
* (c) 2020 Yurii Derevych

@@ -18,3 +18,3 @@ * Released under the BSD-2-Clause License.

version = '1.1.3';
version = '1.1.4';
private defaults: FormatMoneyOptions = {

@@ -21,0 +21,0 @@ grouping: true,

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc