33 ArrayPrototypeForEach,
44 ArrayPrototypeJoin,
55 ArrayPrototypePush,
6+ DatePrototypeToISOString,
67 ObjectEntries,
78 RegExpPrototypeSymbolReplace,
89 RegExpPrototypeSymbolSplit,
@@ -125,24 +126,28 @@ function tapEscape(input) {
125126}
126127
127128function jsToYaml ( indent , name , value , seen ) {
128- if ( value === null || value === undefined ) {
129+ if ( value === undefined ) {
129130 return '' ;
130131 }
131132
132- if ( typeof value !== 'object' ) {
133- const prefix = `${ indent } ${ name } : ` ;
133+ const prefix = `${ indent } ${ name } :` ;
134+
135+ if ( value === null ) {
136+ return `${ prefix } ~\n` ;
137+ }
134138
139+ if ( typeof value !== 'object' ) {
135140 if ( typeof value !== 'string' ) {
136- return `${ prefix } ${ inspectWithNoCustomRetry ( value , inspectOptions ) } \n` ;
141+ return `${ prefix } ${ inspectWithNoCustomRetry ( value , inspectOptions ) } \n` ;
137142 }
138143
139144 const lines = RegExpPrototypeSymbolSplit ( kLineBreakRegExp , value ) ;
140145
141146 if ( lines . length === 1 ) {
142- return `${ prefix } ${ inspectWithNoCustomRetry ( value , inspectOptions ) } \n` ;
147+ return `${ prefix } ${ inspectWithNoCustomRetry ( value , inspectOptions ) } \n` ;
143148 }
144149
145- let str = `${ prefix } |-\n` ;
150+ let str = `${ prefix } |-\n` ;
146151
147152 for ( let i = 0 ; i < lines . length ; i ++ ) {
148153 str += `${ indent } ${ lines [ i ] } \n` ;
@@ -154,11 +159,16 @@ function jsToYaml(indent, name, value, seen) {
154159 seen . add ( value ) ;
155160 const entries = ObjectEntries ( value ) ;
156161 const isErrorObj = isError ( value ) ;
157- let result = '' ;
158162 let propsIndent = indent ;
163+ let result = '' ;
159164
160165 if ( name != null ) {
161- result += `${ indent } ${ name } :\n` ;
166+ result += prefix ;
167+ if ( internalBinding ( 'types' ) . isDate ( value ) ) {
168+ // YAML uses the ISO-8601 standard to express dates.
169+ result += ' ' + DatePrototypeToISOString ( value ) ;
170+ }
171+ result += '\n' ;
162172 propsIndent += ' ' ;
163173 }
164174
0 commit comments