File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ function visit(
81
81
// Get the simple cases out of the way first
82
82
if (
83
83
value == null || // this matches null and undefined -> eqeq not eqeqeq
84
- ( [ 'number' , 'boolean' , 'string' ] . includes ( typeof value ) && ! Number . isNaN ( value ) )
84
+ ( [ 'number' , 'boolean' , 'string' ] . includes ( typeof value ) && Number . isFinite ( value ) )
85
85
) {
86
86
return value as Primitive ;
87
87
}
@@ -224,6 +224,14 @@ function stringifyValue(
224
224
return '[NaN]' ;
225
225
}
226
226
227
+ if ( typeof value === 'number' && value === Infinity ) {
228
+ return '[Infinity]' ;
229
+ }
230
+
231
+ if ( typeof value === 'number' && value === - Infinity ) {
232
+ return '[-Infinity]' ;
233
+ }
234
+
227
235
if ( typeof value === 'function' ) {
228
236
return `[Function: ${ getFunctionName ( value ) } ]` ;
229
237
}
Original file line number Diff line number Diff line change @@ -403,6 +403,8 @@ describe('normalize()', () => {
403
403
describe ( 'changes unserializeable/global values/classes to their respective string representations' , ( ) => {
404
404
test ( 'primitive values' , ( ) => {
405
405
expect ( normalize ( NaN ) ) . toEqual ( '[NaN]' ) ;
406
+ expect ( normalize ( Infinity ) ) . toEqual ( '[Infinity]' ) ;
407
+ expect ( normalize ( - Infinity ) ) . toEqual ( '[-Infinity]' ) ;
406
408
expect ( normalize ( Symbol ( 'dogs' ) ) ) . toEqual ( '[Symbol(dogs)]' ) ;
407
409
expect ( normalize ( BigInt ( 1121201212312012 ) ) ) . toEqual ( '[BigInt: 1121201212312012]' ) ;
408
410
} ) ;
You can’t perform that action at this time.
0 commit comments