format-money-js
Advanced tools
Comparing version 1.5.1 to 1.5.2
@@ -29,4 +29,4 @@ /*! | ||
constructor(options?: FormatMoneyOptions); | ||
from: (number: number, options: FormatMoneyOptions | {}, parse?: boolean) => string | number | FormatMoneyParse | undefined; | ||
from: (number: number, options?: FormatMoneyOptions | {}, parse?: boolean) => string | number | FormatMoneyParse | undefined; | ||
un: (value: (string | number), options: FormatMoneyOptions) => number | undefined; | ||
} |
@@ -13,3 +13,3 @@ "use strict"; | ||
this.options = options; | ||
this.version = '1.5.0'; | ||
this.version = '1.5.2'; | ||
this.defaults = { | ||
@@ -24,3 +24,3 @@ grouping: true, | ||
}; | ||
this.from = (number, options, parse = false) => { | ||
this.from = (number, options = {}, parse = false) => { | ||
const opt = Object.assign(Object.assign({}, this.options), options); | ||
@@ -27,0 +27,0 @@ if (typeof number !== 'number') |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FormatMoney=void 0;class FormatMoney{constructor(e){this.options=e,this.version="1.5.0",this.defaults={grouping:!0,separator:",",decimalPoint:".",decimals:0,symbol:"",append:!1,leadZeros:!0},this.from=((e,t,s=!1)=>{const o=Object.assign(Object.assign({},this.options),t);if("number"!=typeof e)return;const i=e<0?"-":"";let n,r,a,l,c,p,m;if(n=Math.abs(e).toFixed(o.decimals),!1===o.leadZeros){n=parseFloat(n).toString()}if(a=(r=n.split("."))[0],l=r.length>1?o.decimalPoint+r[1]:"",o.grouping){c="";for(let e=0,t=a.length;e<t;e+=1)0!==e&&e%3==0&&(c=o.separator+c),c=a[t-e-1]+c;a=c}return p=m="",o.append?m=o.symbol:p=o.symbol,s?{source:e,negative:e<0,fullAmount:a+l,amount:a,decimals:l,symbol:o.symbol}:i+p+a+l+m}),this.un=((e,t)=>{const s=Object.assign(Object.assign({},this.options),t);if("number"==typeof e)return e;if("string"!=typeof e)return;const o=new RegExp(`[^0-9-${s.decimalPoint}]`,"g"),i=parseFloat(e.replace(/\((?=\d+)(.*)\)/,"-$1").replace(o,"").replace(`${s.decimalPoint}`,"."));return isNaN(i)?0:i}),this.options=Object.assign(Object.assign({},this.defaults),e)}}exports.FormatMoney=FormatMoney; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.FormatMoney=void 0;class FormatMoney{constructor(e){this.options=e,this.version="1.5.2",this.defaults={grouping:!0,separator:",",decimalPoint:".",decimals:0,symbol:"",append:!1,leadZeros:!0},this.from=((e,t={},s=!1)=>{const o=Object.assign(Object.assign({},this.options),t);if("number"!=typeof e)return;const i=e<0?"-":"";let n,r,a,l,c,p,m;if(n=Math.abs(e).toFixed(o.decimals),!1===o.leadZeros){n=parseFloat(n).toString()}if(a=(r=n.split("."))[0],l=r.length>1?o.decimalPoint+r[1]:"",o.grouping){c="";for(let e=0,t=a.length;e<t;e+=1)0!==e&&e%3==0&&(c=o.separator+c),c=a[t-e-1]+c;a=c}return p=m="",o.append?m=o.symbol:p=o.symbol,s?{source:e,negative:e<0,fullAmount:a+l,amount:a,decimals:l,symbol:o.symbol}:i+p+a+l+m}),this.un=((e,t)=>{const s=Object.assign(Object.assign({},this.options),t);if("number"==typeof e)return e;if("string"!=typeof e)return;const o=new RegExp(`[^0-9-${s.decimalPoint}]`,"g"),i=parseFloat(e.replace(/\((?=\d+)(.*)\)/,"-$1").replace(o,"").replace(`${s.decimalPoint}`,"."));return isNaN(i)?0:i}),this.options=Object.assign(Object.assign({},this.defaults),e)}}exports.FormatMoney=FormatMoney; |
{ | ||
"name": "format-money-js", | ||
"description": "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": "1.5.1", | ||
"version": "1.5.2", | ||
"license": "BSD-2-Clause", | ||
@@ -6,0 +6,0 @@ "main": "./dist/format-money.js", |
@@ -29,3 +29,3 @@ /*! | ||
version = '1.5.0'; | ||
version = '1.5.2'; | ||
private defaults: FormatMoneyOptions = { | ||
@@ -51,3 +51,3 @@ grouping: true, | ||
from = (number: number, | ||
options: FormatMoneyOptions | {}, | ||
options: FormatMoneyOptions | {} = {}, | ||
parse: boolean = false): string | number | FormatMoneyParse | undefined => { | ||
@@ -54,0 +54,0 @@ const opt = { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23430