@@ -219,17 +219,52 @@ class ObjectPreview {
219
219
[ customInspectSymbol ] ( depth , opts ) {
220
220
switch ( this . type ) {
221
221
case 'object' : {
222
- const props = ArrayPrototypeMap ( this . properties , ( prop , idx ) => {
223
- const value = utilInspect ( new PropertyPreview ( prop ) ) ;
224
- if ( prop . name === `${ idx } ` ) return value ;
225
- return `${ prop . name } : ${ value } ` ;
226
- } ) ;
227
- if ( this . overflow ) {
228
- ArrayPrototypePush ( props , '...' ) ;
222
+ switch ( this . subtype ) {
223
+ case 'date' :
224
+ return utilInspect ( new Date ( this . description ) , opts ) ;
225
+ case 'null' :
226
+ return utilInspect ( null , opts ) ;
227
+ case 'regexp' :
228
+ return opts . stylize ( this . description , 'regexp' ) ;
229
+ case 'set' : {
230
+ if ( ! this . entries ) {
231
+ return `${ this . description } ${ this . overflow ? '{ ... }' : '{}' } ` ;
232
+ }
233
+ const values = ArrayPrototypeMap ( this . entries , ( entry ) =>
234
+ utilInspect ( new ObjectPreview ( entry . value ) , opts ) ) ;
235
+ return `${ this . description } { ${ ArrayPrototypeJoin ( values , ', ' ) } }` ;
236
+ }
237
+ case 'map' : {
238
+ if ( ! this . entries ) {
239
+ return `${ this . description } ${ this . overflow ? '{ ... }' : '{}' } ` ;
240
+ }
241
+ const mappings = ArrayPrototypeMap ( this . entries , ( entry ) => {
242
+ const key = utilInspect ( new ObjectPreview ( entry . key ) , opts ) ;
243
+ const value = utilInspect ( new ObjectPreview ( entry . value ) , opts ) ;
244
+ return `${ key } => ${ value } ` ;
245
+ } ) ;
246
+ return `${ this . description } { ${ ArrayPrototypeJoin ( mappings , ', ' ) } }` ;
247
+ }
248
+ case 'array' :
249
+ case undefined : {
250
+ if ( this . properties . length === 0 ) {
251
+ return this . subtype === 'array' ? '[]' : '{}' ;
252
+ }
253
+ const props = ArrayPrototypeMap ( this . properties , ( prop , idx ) => {
254
+ const value = utilInspect ( new PropertyPreview ( prop ) ) ;
255
+ if ( prop . name === `${ idx } ` ) return value ;
256
+ return `${ prop . name } : ${ value } ` ;
257
+ } ) ;
258
+ if ( this . overflow ) {
259
+ ArrayPrototypePush ( props , '...' ) ;
260
+ }
261
+ const singleLine = ArrayPrototypeJoin ( props , ', ' ) ;
262
+ const propString = singleLine . length > 60 ? ArrayPrototypeJoin ( props , ',\n ' ) : singleLine ;
263
+ return this . subtype === 'array' ? `[ ${ propString } ]` : `{ ${ propString } }` ;
264
+ }
265
+ default :
266
+ return this . description ;
229
267
}
230
- const singleLine = ArrayPrototypeJoin ( props , ', ' ) ;
231
- const propString = singleLine . length > 60 ? ArrayPrototypeJoin ( props , ',\n ' ) : singleLine ;
232
- return this . subtype === 'array' ? `[ ${ propString } ]` : `{ ${ propString } }` ;
233
268
}
234
269
default :
235
270
return this . description ;
@@ -268,6 +303,11 @@ class RemoteObject {
268
303
return utilInspect ( null , opts ) ;
269
304
case 'regexp' :
270
305
return opts . stylize ( this . description , 'regexp' ) ;
306
+ case 'map' :
307
+ case 'set' : {
308
+ const preview = utilInspect ( new ObjectPreview ( this . preview ) , opts ) ;
309
+ return `${ this . description } ${ preview } ` ;
310
+ }
271
311
default :
272
312
break ;
273
313
}
0 commit comments