Skip to content

Commit e64905e

Browse files
committed
2.0.6
1 parent 1766d8e commit e64905e

File tree

5 files changed

+10
-21
lines changed

5 files changed

+10
-21
lines changed

README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ And a jsFiddle was created to aid in testing: https://jsfiddle.net/Mottie/t2etyo
7171

7272
View the [complete change log here](https://github.com/Mottie/javascript-number-formatter/wiki).
7373

74+
### V2.0.6 (2018-11-06)
75+
76+
* Trim trailing zeros in mask. Fixes [issue #18](https://github.com/Mottie/javascript-number-formatter/issues/18).
77+
7478
### v2.0.0 – 2.0.5 (2018-10-26)
7579

7680
* Add `ignoreSign` option (modified to `enforeceMaskSign`!).
@@ -97,16 +101,3 @@ View the [complete change log here](https://github.com/Mottie/javascript-number-
97101
* Demo:
98102
* Fix prettify loading.
99103
* Use https. Fixes [issue #13](https://github.com/Mottie/javascript-number-formatter/issues/13).
100-
101-
### v1.1.11 (2017-01-31)
102-
103-
* Readme:
104-
* Update log.
105-
* Add playground link.
106-
* Reword note.
107-
* Meta:
108-
* Update dependencies.
109-
* Remove GPL portion of the license & update `package.json` entry.
110-
* Fix `bower.json` "main" reference.
111-
* Build:
112-
* Fix build process to use the updated `package.json` license format.

lib/format.esm.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @copyright 2018 ecava
99
* @license MIT
1010
* @link http://mottie.github.com/javascript-number-formatter/
11-
* @version 2.0.5
11+
* @version 2.0.6
1212
*/
1313
const maskRegex = /[0-9\-+#]/;
1414
const notMaskRegex = /[^\d\-+#]/g;
@@ -65,12 +65,11 @@ function processValue(value, maskObj, options) {
6565
// Fix the decimal first, toFixed will auto fill trailing zero.
6666
valObj.value = Number(valObj.value).toFixed(maskObj.fraction && maskObj.fraction.length);
6767
// Convert number to string to trim off *all* trailing decimal zero(es)
68-
valObj.value = valObj.value.toString();
68+
valObj.value = Number(valObj.value).toString();
6969

7070
// Fill back any trailing zero according to format
7171
// look for last zero in format
7272
const posTrailZero = maskObj.fraction && maskObj.fraction.lastIndexOf("0");
73-
7473
let [valInteger = "0", valFraction = ""] = valObj.value.split(".");
7574
if (!valFraction || (valFraction && valFraction.length <= posTrailZero)) {
7675
valFraction = (Number("0." + valFraction).toFixed(posTrailZero + 1)).replace("0.", "");

lib/format.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @copyright 2018 ecava
99
* @license MIT
1010
* @link http://mottie.github.com/javascript-number-formatter/
11-
* @version 2.0.5
11+
* @version 2.0.6
1212
*/
1313
(function (global, factory) {
1414
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -71,12 +71,11 @@
7171
// Fix the decimal first, toFixed will auto fill trailing zero.
7272
valObj.value = Number(valObj.value).toFixed(maskObj.fraction && maskObj.fraction.length);
7373
// Convert number to string to trim off *all* trailing decimal zero(es)
74-
valObj.value = valObj.value.toString();
74+
valObj.value = Number(valObj.value).toString();
7575

7676
// Fill back any trailing zero according to format
7777
// look for last zero in format
7878
const posTrailZero = maskObj.fraction && maskObj.fraction.lastIndexOf("0");
79-
8079
let [valInteger = "0", valFraction = ""] = valObj.value.split(".");
8180
if (!valFraction || (valFraction && valFraction.length <= posTrailZero)) {
8281
valFraction = (Number("0." + valFraction).toFixed(posTrailZero + 1)).replace("0.", "");

lib/format.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "number-format.js",
33
"nick": "javascript-number-formatter",
44
"description": "Lightweight & Fast JavaScript Number Formatter",
5-
"version": "2.0.5",
5+
"version": "2.0.6",
66
"homepage": "http://mottie.github.com/javascript-number-formatter/",
77
"main": "lib/format.min.js",
88
"demo": "https://github.com/Mottie/javascript-number-formatter/index.html",

0 commit comments

Comments
 (0)