File tree Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Expand file tree Collapse file tree 2 files changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -205,7 +205,9 @@ function stringifyPrimitive(thing: any) {
205
205
if ( typeof thing === 'string' ) return JSON . stringify ( thing ) . replace ( unsafe , escape ) ;
206
206
if ( thing === void 0 ) return 'void 0' ;
207
207
if ( thing === 0 && 1 / thing < 0 ) return '-0' ;
208
- return String ( thing ) ;
208
+ const str = String ( thing ) ;
209
+ if ( typeof thing === 'number' ) return str . replace ( / ^ ( - ) ? 0 \. / , '$1.' ) ;
210
+ return str ;
209
211
}
210
212
211
213
function getType ( thing : any ) {
Original file line number Diff line number Diff line change @@ -14,6 +14,8 @@ describe('devalue', () => {
14
14
test ( 'number' , 42 , '42' ) ;
15
15
test ( 'negative number' , - 42 , '-42' ) ;
16
16
test ( 'negative zero' , - 0 , '-0' ) ;
17
+ test ( 'positive decimal' , 0.1 , '.1' ) ;
18
+ test ( 'negative decimal' , - 0.1 , '-.1' ) ;
17
19
test ( 'string' , 'woo!!!' , '"woo!!!"' ) ;
18
20
test ( 'boolean' , true , 'true' ) ;
19
21
test ( 'Number' , new Number ( 42 ) , 'Object(42)' ) ;
You can’t perform that action at this time.
0 commit comments