Socket
Socket
Sign inDemoInstall

number-format.js

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.7 to 2.0.8

lib/format.es5.js

4

lib/format.esm.js

@@ -8,6 +8,6 @@ /**

* @maintainer Rob Garrison
* @copyright 2018 ecava
* @copyright 2019 ecava
* @license MIT
* @link http://mottie.github.com/javascript-number-formatter/
* @version 2.0.7
* @version 2.0.8
*/

@@ -14,0 +14,0 @@ const maskRegex = /[0-9\-+#]/;

@@ -8,6 +8,6 @@ /**

* @maintainer Rob Garrison
* @copyright 2018 ecava
* @copyright 2019 ecava
* @license MIT
* @link http://mottie.github.com/javascript-number-formatter/
* @version 2.0.7
* @version 2.0.8
*/

@@ -14,0 +14,0 @@ (function (global, factory) {

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

/*! Javascript-number-formatter v2.0.7 */
/*! Javascript-number-formatter v2.0.8 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.format=t()}(this,function(){"use strict";const e=/[0-9\-+#]/,t=/[^\d\-+#]/g;function n(t){return t.search(e)}return(e,i,r={})=>{if(!e||isNaN(Number(i)))return i;const s=function(e="#.##"){const i={},r=e.length,s=n(e);i.prefix=s>0?e.substring(0,s):"";const a=n(e.split("").reverse().join("")),o=r-a,u=e.substring(o,o+1),l=o+("."===u||","===u?1:0);i.suffix=a>0?e.substring(l,r):"",i.mask=e.substring(s,l),i.maskHasNegativeSign="-"===i.mask.charAt(0),i.maskHasPositiveSign="+"===i.mask.charAt(0);let g=i.mask.match(t);return i.decimal=g&&g[g.length-1]||".",i.separator=g&&g[1]&&g[0]||",",g=i.mask.split(i.decimal),i.integer=g[0],i.fraction=g[1],i}(e),a=function(e,t,n){let i=!1;const r={value:e};e<0&&(i=!0,r.value=-r.value),r.sign=i?"-":"",r.value=Number(r.value).toFixed(t.fraction&&t.fraction.length),r.value=Number(r.value).toString();const s=t.fraction&&t.fraction.lastIndexOf("0");let[a="0",o=""]=r.value.split(".");return(!o||o&&o.length<=s)&&(o=s<0?"":Number("0."+o).toFixed(s+1).replace("0.","")),r.integer=a,r.fraction=o,function(e,t){e.result="";const n=t.integer.split(t.separator),i=n.join(""),r=i&&i.indexOf("0");if(r>-1)for(;e.integer.length<i.length-r;)e.integer="0"+e.integer;else 0===Number(e.integer)&&(e.integer="");const s=n[1]&&n[n.length-1].length;if(s){const n=e.integer.length,i=n%s;for(let r=0;r<n;r++)e.result+=e.integer.charAt(r),!((r-i+1)%s)&&r<n-s&&(e.result+=t.separator)}else e.result=e.integer;e.result+=t.fraction&&e.fraction?t.decimal+e.fraction:""}(r,t),"0"!==r.result&&""!==r.result||(i=!1,r.sign=""),!i&&t.maskHasPositiveSign?r.sign="+":i&&t.maskHasPositiveSign?r.sign="-":i&&(r.sign=n&&n.enforceMaskSign&&!t.maskHasNegativeSign?"":"-"),r}(i,s,r);return s.prefix+a.sign+a.result+s.suffix}});

@@ -5,3 +5,3 @@ {

"description": "Lightweight & Fast JavaScript Number Formatter",
"version": "2.0.7",
"version": "2.0.8",
"homepage": "http://mottie.github.com/javascript-number-formatter/",

@@ -66,10 +66,14 @@ "main": "lib/format.min.js",

"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/preset-env": "^7.3.1",
"ava": "*",
"rollup": "^0.67.1",
"rollup": "^1.1.2",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-cjs-es": "^0.7.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-terser": "^3.0.0",
"updates": "^5.1.2",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-terser": "^4.0.3",
"updates": "^6.2.1",
"xo": "*"
}
}

@@ -59,2 +59,8 @@ # Javascript Number Formatter

## Note
When only one symbol is supplied, the library will always treat that symbol as a decimal. For example, `format( '#,###', 1234567.890)` will output `1234567,890`.
To force a single symbol to be used as a separator, add a trailing symbol. In this example, a period is added to the end of the mask - `format( '#,###.', 1234567.890)` - resulting in it being used as a decimal and forcing the first symbol to be the separator and return this output: `1,234,567`.
## Installation

@@ -66,8 +72,2 @@

## Note
When only one symbol is supplied, the library will always treat that symbol as a decimal. For example, `format( '#,###', 1234567.890)` will output `1234567,890`.
To force a single symbol to be used as a separator, add a trailing symbol. In this example, a period is added to the end of the mask - `format( '#,###.', 1234567.890)` - resulting in it being used as a decimal and forcing the first symbol to be the separator and return this output: `1,234,567`.
## Demos

@@ -74,0 +74,0 @@

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