File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,10 @@ function stringify(obj) {
5
5
if ( obj instanceof Date ) {
6
6
return 'new Date(' + stringify ( obj . toISOString ( ) ) + ')' ;
7
7
}
8
+ if ( obj === undefined ) {
9
+ return 'undefined' ;
10
+ }
8
11
return JSON . stringify ( obj )
9
12
. replace ( / \u2028 / g, '\\u2028' )
10
13
. replace ( / \u2029 / g, '\\u2029' ) ;
11
- }
14
+ }
Original file line number Diff line number Diff line change @@ -7,5 +7,7 @@ assert(stringify('foo') === '"foo"');
7
7
assert ( stringify ( 'foo\u2028bar\u2029baz' ) === '"foo\\u2028bar\\u2029baz"' ) ;
8
8
assert ( stringify ( new Date ( '2014-12-19T03:42:00.000Z' ) ) === 'new Date("2014-12-19T03:42:00.000Z")' ) ;
9
9
assert ( stringify ( { foo : 'bar' } ) === '{"foo":"bar"}' ) ;
10
+ assert ( stringify ( undefined ) === 'undefined' ) ;
11
+ assert ( stringify ( null ) === 'null' ) ;
10
12
11
13
console . log ( 'tests passed' ) ;
You can’t perform that action at this time.
0 commit comments