File tree Expand file tree Collapse file tree 1 file changed +15
-17
lines changed Expand file tree Collapse file tree 1 file changed +15
-17
lines changed Original file line number Diff line number Diff line change @@ -12,27 +12,25 @@ var BADNUM = numConstants.BADNUM;
12
12
var lib = module . exports = { } ;
13
13
14
14
lib . adjustFormat = function ( a ) {
15
- if ( ! a ) return a ;
16
- var b = a ;
17
- if ( b === '0.f' ) return '~f' ;
18
- if ( / ^ [ 0 1 2 3 4 5 6 7 8 9 ] .[ 0 1 2 3 4 5 6 7 8 9 ] f / . test ( b ) ) return a ;
19
- if ( / .[ 0 1 2 3 4 5 6 7 8 9 ] % / . test ( b ) ) return a ;
20
- if ( / ^ [ 0 1 2 3 4 5 6 7 8 9 ] % / . test ( b ) ) return '~%' ;
21
- if ( / ^ [ 0 1 2 3 4 5 6 7 8 9 ] s / . test ( b ) ) return '~s' ;
22
- if ( ! ( / ^ [ ~ , . 0 $ ] / . test ( b ) ) && / [ & f p s ] / . test ( b ) ) {
23
- // try adding tilde to the start of format in order to trim
24
- b = '~' + b ;
25
- }
26
- return b ;
15
+ if (
16
+ ! a ||
17
+ / ^ [ 0 1 2 3 4 5 6 7 8 9 ] .[ 0 1 2 3 4 5 6 7 8 9 ] f / . test ( a ) ||
18
+ / .[ 0 1 2 3 4 5 6 7 8 9 ] % / . test ( a )
19
+ ) return a ;
20
+
21
+ if ( a === '0.f' ) return '~f' ;
22
+ if ( / ^ [ 0 1 2 3 4 5 6 7 8 9 ] % / . test ( a ) ) return '~%' ;
23
+ if ( / ^ [ 0 1 2 3 4 5 6 7 8 9 ] s / . test ( a ) ) return '~s' ;
24
+
25
+ // try adding tilde to the start of format in order to trim
26
+ if ( ! ( / ^ [ ~ , . 0 $ ] / . test ( a ) ) && / [ & f p s ] / . test ( a ) ) return '~' + a ;
27
+
28
+ return a ;
27
29
} ;
28
30
29
31
var d3Format = require ( 'd3-format' ) . format ;
30
32
var numberFormat = function ( a ) {
31
- var b = lib . adjustFormat ( a ) ;
32
-
33
- // console.log('"' + a + '" > "' + b + '"');
34
-
35
- return d3Format ( b ) ;
33
+ return d3Format ( lib . adjustFormat ( a ) ) ;
36
34
} ;
37
35
lib . numberFormat = numberFormat ;
38
36
You can’t perform that action at this time.
0 commit comments