Skip to content

Commit

Permalink
fix: numberForm 千位符整数处理
Browse files Browse the repository at this point in the history
  • Loading branch information
paopaotang committed Jul 30, 2020
1 parent e96721b commit 105b5b3
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion dist/eagle.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,8 @@
var dropLast$1 = _curry2(_dispatchable([], _xdropLast, dropLast));

function getAfterDecimalPointLeng(num) {
return (num || 0).toString().split('.')[1].length || 0;
var point = (num || 0).toString().split('.')[1];
return point && point.length ? point.length : 0;
}

function toThousands(num) {
Expand Down
2 changes: 1 addition & 1 deletion dist/eagle.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion es/numberFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import _curry1 from "./internal/_curry1.js";
import isEmpty from "./isEmpty.js";

function getAfterDecimalPointLeng(num) {
return (num || 0).toString().split('.')[1].length || 0;
var point = (num || 0).toString().split('.')[1];
return point && point.length ? point.length : 0;
}

function toThousands(num) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@interaction/eagle",
"version": "0.0.6",
"version": "0.0.7",
"description": "JavaScript library",
"keywords": [
"eagle",
Expand Down
3 changes: 2 additions & 1 deletion source/numberFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import _curry1 from './internal/_curry1';
import isEmpty from './isEmpty';

function getAfterDecimalPointLeng(num) {
return (num || 0).toString().split('.')[1].length || 0;
var point = (num || 0).toString().split('.')[1];
return (point && point.length) ? point.length : 0;
}

function toThousands(num) {
Expand Down
3 changes: 2 additions & 1 deletion src/numberFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ var _curry1 = /*#__PURE__*/require("./internal/_curry1");
var isEmpty = /*#__PURE__*/require("./isEmpty");

function getAfterDecimalPointLeng(num) {
return (num || 0).toString().split('.')[1].length || 0;
var point = (num || 0).toString().split('.')[1];
return point && point.length ? point.length : 0;
}

function toThousands(num) {
Expand Down
3 changes: 3 additions & 0 deletions test/numberFormat.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ test('1', t => {
test('numberFormat: The digits are set in thousands', t => {
t.is(E.numberFormat(19935555556999.22666, { thousandSeparator: true }), '19,935,555,556,999.227');
});
test('numberFormat: The integer are set in thousands', t => {
t.is(E.numberFormat(19935555556999, { thousandSeparator: true }), '19,935,555,556,999');
});
test('numberFormat: Number decimal setting', t => {
t.is(E.numberFormat(19935555556999.22666, { decimalPlace: 2 }), 19935555556999.23);
});
Expand Down

0 comments on commit 105b5b3

Please sign in to comment.