Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.5.2 to 1.5.3

4

dist/format-money.d.ts
/*!
* format-money-js v1.5.1
* format-money-js v1.5.3
* (c) 2020-2022 Yurii Derevych

@@ -14,3 +14,3 @@ * Sponsored by https://currencyrate.today/

append?: boolean;
leadZeros: boolean;
leadZeros?: boolean;
}

@@ -17,0 +17,0 @@ export interface FormatMoneyParse {

"use strict";
/*!
* format-money-js v1.5.1
* format-money-js v1.5.3
* (c) 2020-2022 Yurii Derevych

@@ -36,3 +36,3 @@ * Sponsored by https://currencyrate.today/

result = Math.abs(number).toFixed(opt.decimals);
if (opt.leadZeros === false) {
if (!opt.leadZeros) {
const resultFloat = parseFloat(result);

@@ -39,0 +39,0 @@ result = resultFloat.toString();

@@ -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.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;
"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),!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.2",
"version": "1.5.3",
"license": "BSD-2-Clause",

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

/*!
* format-money-js v1.5.1
* format-money-js v1.5.3
* (c) 2020-2022 Yurii Derevych

@@ -15,3 +15,3 @@ * Sponsored by https://currencyrate.today/

append?: boolean;
leadZeros: boolean;
leadZeros?: boolean;
}

@@ -71,5 +71,5 @@

result = Math.abs(number).toFixed(opt.decimals);
if (opt.leadZeros === false) {
const resultFloat = parseFloat(result)
result = resultFloat.toString()
if (!opt.leadZeros) {
const resultFloat = parseFloat(result);
result = resultFloat.toString();
}

@@ -76,0 +76,0 @@ x = result.split('.');

Sorry, the diff of this file is not supported yet

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