@@ -490,7 +490,7 @@ function formatValue(ctx, value, recurseTimes, ln) {
490
490
const formatted = formatPrimitive ( stylizeNoColor , raw , ctx ) ;
491
491
if ( keyLength === raw . length )
492
492
return ctx . stylize ( `[String: ${ formatted } ]` , 'string' ) ;
493
- base = ` [String: ${ formatted } ]` ;
493
+ base = `[String: ${ formatted } ]` ;
494
494
// For boxed Strings, we have to remove the 0-n indexed entries,
495
495
// since they just noisy up the output and are redundant
496
496
// Make boxed primitive Strings look like such
@@ -512,25 +512,25 @@ function formatValue(ctx, value, recurseTimes, ln) {
512
512
`${ constructor || tag } ${ value . name ? `: ${ value . name } ` : '' } ` ;
513
513
if ( keyLength === 0 )
514
514
return ctx . stylize ( `[${ name } ]` , 'special' ) ;
515
- base = ` [${ name } ]` ;
515
+ base = `[${ name } ]` ;
516
516
} else if ( isRegExp ( value ) ) {
517
517
// Make RegExps say that they are RegExps
518
518
if ( keyLength === 0 || recurseTimes < 0 )
519
519
return ctx . stylize ( regExpToString . call ( value ) , 'regexp' ) ;
520
- base = ` ${ regExpToString . call ( value ) } ` ;
520
+ base = `${ regExpToString . call ( value ) } ` ;
521
521
} else if ( isDate ( value ) ) {
522
522
if ( keyLength === 0 ) {
523
523
if ( Number . isNaN ( value . getTime ( ) ) )
524
524
return ctx . stylize ( value . toString ( ) , 'date' ) ;
525
525
return ctx . stylize ( dateToISOString . call ( value ) , 'date' ) ;
526
526
}
527
527
// Make dates with properties first say the date
528
- base = ` ${ dateToISOString . call ( value ) } ` ;
528
+ base = `${ dateToISOString . call ( value ) } ` ;
529
529
} else if ( isError ( value ) ) {
530
530
// Make error with message first say the error
531
531
if ( keyLength === 0 )
532
532
return formatError ( value ) ;
533
- base = ` ${ formatError ( value ) } ` ;
533
+ base = `${ formatError ( value ) } ` ;
534
534
} else if ( isAnyArrayBuffer ( value ) ) {
535
535
// Fast path for ArrayBuffer and SharedArrayBuffer.
536
536
// Can't do the same for DataView because it has a non-primitive
@@ -560,13 +560,13 @@ function formatValue(ctx, value, recurseTimes, ln) {
560
560
const formatted = formatPrimitive ( stylizeNoColor , raw ) ;
561
561
if ( keyLength === 0 )
562
562
return ctx . stylize ( `[Number: ${ formatted } ]` , 'number' ) ;
563
- base = ` [Number: ${ formatted } ]` ;
563
+ base = `[Number: ${ formatted } ]` ;
564
564
} else if ( typeof raw === 'boolean' ) {
565
565
// Make boxed primitive Booleans look like such
566
566
const formatted = formatPrimitive ( stylizeNoColor , raw ) ;
567
567
if ( keyLength === 0 )
568
568
return ctx . stylize ( `[Boolean: ${ formatted } ]` , 'boolean' ) ;
569
- base = ` [Boolean: ${ formatted } ]` ;
569
+ base = `[Boolean: ${ formatted } ]` ;
570
570
} else if ( typeof raw === 'symbol' ) {
571
571
const formatted = formatPrimitive ( stylizeNoColor , raw ) ;
572
572
return ctx . stylize ( `[Symbol: ${ formatted } ]` , 'symbol' ) ;
@@ -890,8 +890,7 @@ function reduceToSingleString(ctx, output, base, braces, addLn) {
890
890
var i = 0 ;
891
891
if ( ctx . structured === true ) {
892
892
const indentation = ' ' . repeat ( ctx . indentationLvl ) ;
893
- var res = braces [ 0 ] ;
894
- res += `${ base } \n${ indentation } ` ;
893
+ var res = `${ base ? `${ base } ` : '' } ${ braces [ 0 ] } \n${ indentation } ` ;
895
894
for ( ; i < output . length - 1 ; i ++ ) {
896
895
res += `${ output [ i ] } ,\n${ indentation } ` ;
897
896
}
@@ -908,15 +907,16 @@ function reduceToSingleString(ctx, output, base, braces, addLn) {
908
907
}
909
908
}
910
909
if ( length <= breakLength )
911
- return `${ braces [ 0 ] } ${ base } ${ join ( output , ', ' ) } ${ braces [ 1 ] } ` ;
910
+ return `${ braces [ 0 ] } ${ base ? ` ${ base } ` : '' } ${ join ( output , ', ' ) } ` +
911
+ braces [ 1 ] ;
912
912
}
913
913
// If the opening "brace" is too large, like in the case of "Set {",
914
914
// we need to force the first item to be on the next line or the
915
915
// items will not line up correctly.
916
916
const indentation = ' ' . repeat ( ctx . indentationLvl ) ;
917
917
const extraLn = addLn === true ? `\n${ indentation } ` : '' ;
918
918
const ln = base === '' && braces [ 0 ] . length === 1 ?
919
- ' ' : `${ base } \n${ indentation } ` ;
919
+ ' ' : `${ base ? ` ${ base } ` : base } \n${ indentation } ` ;
920
920
const str = join ( output , `,\n${ indentation } ` ) ;
921
921
return `${ extraLn } ${ braces [ 0 ] } ${ ln } ${ str } ${ braces [ 1 ] } ` ;
922
922
}
0 commit comments