@ -195,6 +195,7 @@ function ensureDebugIsInitialized() {
function inspectPromise ( p ) {
function inspectPromise ( p ) {
ensureDebugIsInitialized ( ) ;
ensureDebugIsInitialized ( ) ;
// Only create a mirror if the object is a Promise.
if ( ! binding . isPromise ( p ) )
if ( ! binding . isPromise ( p ) )
return null ;
return null ;
const mirror = Debug . MakeMirror ( p , true ) ;
const mirror = Debug . MakeMirror ( p , true ) ;
@ -289,16 +290,19 @@ function formatValue(ctx, value, recurseTimes) {
var constructor = getConstructorOf ( value ) ;
var constructor = getConstructorOf ( value ) ;
var base = '' , empty = false , braces , formatter ;
var base = '' , empty = false , braces , formatter ;
// We can't compare constructors for various objects using a comparison like
// `constructor === Array` because the object could have come from a different
// context and thus the constructor won't match. Instead we check the
// constructor names (including those up the prototype chain where needed) to
// determine object types.
if ( Array . isArray ( value ) ) {
if ( Array . isArray ( value ) ) {
// We can't use `constructor === Array` because this could
// Unset the constructor to prevent "Array [...]" for ordinary arrays.
// have come from a Debug context.
// Otherwise, an Array will print "Array [...]".
if ( constructor && constructor . name === 'Array' )
if ( constructor && constructor . name === 'Array' )
constructor = null ;
constructor = null ;
braces = [ '[' , ']' ] ;
braces = [ '[' , ']' ] ;
empty = value . length === 0 ;
empty = value . length === 0 ;
formatter = formatArray ;
formatter = formatArray ;
} else if ( value instanceof Set ) {
} else if ( objectToString ( value ) === '[object Set]' ) {
braces = [ '{' , '}' ] ;
braces = [ '{' , '}' ] ;
// With `showHidden`, `length` will display as a hidden property for
// With `showHidden`, `length` will display as a hidden property for
// arrays. For consistency's sake, do the same for `size`, even though this
// arrays. For consistency's sake, do the same for `size`, even though this
@ -307,7 +311,7 @@ function formatValue(ctx, value, recurseTimes) {
keys . unshift ( 'size' ) ;
keys . unshift ( 'size' ) ;
empty = value . size === 0 ;
empty = value . size === 0 ;
formatter = formatSet ;
formatter = formatSet ;
} else if ( value instanceof Map ) {
} else if ( objectToString ( value ) === '[object Map]' ) {
braces = [ '{' , '}' ] ;
braces = [ '{' , '}' ] ;
// Ditto.
// Ditto.
if ( ctx . showHidden )
if ( ctx . showHidden )
@ -315,8 +319,7 @@ function formatValue(ctx, value, recurseTimes) {
empty = value . size === 0 ;
empty = value . size === 0 ;
formatter = formatMap ;
formatter = formatMap ;
} else {
} else {
// Only create a mirror if the object superficially looks like a Promise.
var promiseInternals = inspectPromise ( value ) ;
var promiseInternals = value instanceof Promise && inspectPromise ( value ) ;
if ( promiseInternals ) {
if ( promiseInternals ) {
braces = [ '{' , '}' ] ;
braces = [ '{' , '}' ] ;
formatter = formatPromise ;
formatter = formatPromise ;
@ -332,7 +335,8 @@ function formatValue(ctx, value, recurseTimes) {
empty = false ;
empty = false ;
formatter = formatCollectionIterator ;
formatter = formatCollectionIterator ;
} else {
} else {
if ( constructor === Object )
// Unset the constructor to prevent "Object {...}" for ordinary objects.
if ( constructor && constructor . name === 'Object' )
constructor = null ;
constructor = null ;
braces = [ '{' , '}' ] ;
braces = [ '{' , '}' ] ;
empty = true ; // No other data than keys.
empty = true ; // No other data than keys.