File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
33module . exports = stringify ;
4- function stringify ( obj ) {
4+ function stringify ( obj , indentation ) {
55 if ( obj instanceof Date ) {
66 return 'new Date(' + stringify ( obj . toISOString ( ) ) + ')' ;
77 }
88 if ( obj === undefined ) {
99 return 'undefined' ;
1010 }
11- return JSON . stringify ( obj )
11+ return JSON . stringify ( obj , undefined , indentation )
1212 . replace ( / \u2028 / g, '\\u2028' )
1313 . replace ( / \u2029 / g, '\\u2029' )
1414 . replace ( / < / g, '\\u003C' )
Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ assert(stringify('foo') === '"foo"');
77assert ( stringify ( 'foo\u2028bar\u2029baz' ) === '"foo\\u2028bar\\u2029baz"' ) ;
88assert ( stringify ( new Date ( '2014-12-19T03:42:00.000Z' ) ) === 'new Date("2014-12-19T03:42:00.000Z")' ) ;
99assert ( stringify ( { foo : 'bar' } ) === '{"foo":"bar"}' ) ;
10+ assert ( stringify ( { foo : 'bar' } , undefined ) === '{"foo":"bar"}' ) ;
11+ assert ( stringify ( { foo : 'bar' } , 3 ) === '{\n "foo": "bar"\n}' ) ;
12+ assert ( stringify ( { foo : 'bar' } , ' \t' ) === '{\n \t"foo": "bar"\n}' ) ;
1013assert ( stringify ( undefined ) === 'undefined' ) ;
1114assert ( stringify ( null ) === 'null' ) ;
1215assert (
You can’t perform that action at this time.
0 commit comments