@@ -400,11 +400,14 @@ function formatValue(ctx, value, recurseTimes) {
400400 } ) ;
401401 }
402402
403+ var constructor = getConstructorOf ( value ) ;
404+
403405 // Some type of object without properties can be shortcutted.
404406 if ( keys . length === 0 ) {
405407 if ( typeof value === 'function' ) {
406- return ctx . stylize ( `[Function${ value . name ? `: ${ value . name } ` : '' } ]` ,
407- 'special' ) ;
408+ const ctorName = constructor ? constructor . name : 'Function' ;
409+ return ctx . stylize (
410+ `[${ ctorName } ${ value . name ? `: ${ value . name } ` : '' } ]` , 'special' ) ;
408411 }
409412 if ( isRegExp ( value ) ) {
410413 return ctx . stylize ( RegExp . prototype . toString . call ( value ) , 'regexp' ) ;
@@ -440,12 +443,11 @@ function formatValue(ctx, value, recurseTimes) {
440443 // Can't do the same for DataView because it has a non-primitive
441444 // .buffer property that we need to recurse for.
442445 if ( binding . isArrayBuffer ( value ) || binding . isSharedArrayBuffer ( value ) ) {
443- return `${ getConstructorOf ( value ) . name } ` +
446+ return `${ constructor . name } ` +
444447 ` { byteLength: ${ formatNumber ( ctx , value . byteLength ) } }` ;
445448 }
446449 }
447450
448- var constructor = getConstructorOf ( value ) ;
449451 var base = '' , empty = false , braces ;
450452 var formatter = formatObject ;
451453
@@ -536,7 +538,8 @@ function formatValue(ctx, value, recurseTimes) {
536538
537539 // Make functions say that they are functions
538540 if ( typeof value === 'function' ) {
539- base = ` [Function${ value . name ? `: ${ value . name } ` : '' } ]` ;
541+ const ctorName = constructor ? constructor . name : 'Function' ;
542+ base = ` [${ ctorName } ${ value . name ? `: ${ value . name } ` : '' } ]` ;
540543 }
541544
542545 // Make RegExps say that they are RegExps
0 commit comments