@@ -539,6 +539,15 @@ function formatValue(ctx, value, recurseTimes, typedArray) {
539
539
return formatRaw ( ctx , value , recurseTimes , typedArray ) ;
540
540
}
541
541
542
+ function setIteratorBraces ( type , tag ) {
543
+ if ( tag !== `${ type } Iterator` ) {
544
+ if ( tag !== '' )
545
+ tag += '] [' ;
546
+ tag += `${ type } Iterator` ;
547
+ }
548
+ return [ `[${ tag } ] {` , '}' ] ;
549
+ }
550
+
542
551
function formatRaw ( ctx , value , recurseTimes , typedArray ) {
543
552
let keys ;
544
553
@@ -593,11 +602,11 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
593
602
extrasType = kArrayExtrasType ;
594
603
} else if ( isMapIterator ( value ) ) {
595
604
keys = getKeys ( value , ctx . showHidden ) ;
596
- braces = [ `[ ${ tag } ] {` , '}' ] ;
605
+ braces = setIteratorBraces ( 'Map' , tag ) ;
597
606
formatter = formatIterator ;
598
607
} else if ( isSetIterator ( value ) ) {
599
608
keys = getKeys ( value , ctx . showHidden ) ;
600
- braces = [ `[ ${ tag } ] {` , '}' ] ;
609
+ braces = setIteratorBraces ( 'Set' , tag ) ;
601
610
formatter = formatIterator ;
602
611
} else {
603
612
noIterator = true ;
@@ -729,10 +738,10 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
729
738
}
730
739
}
731
740
if ( isMapIterator ( value ) ) {
732
- braces = [ `[ ${ tag || 'Map Iterator' } ] {` , '}' ] ;
741
+ braces = setIteratorBraces ( 'Map' , tag ) ;
733
742
formatter = formatIterator ;
734
743
} else if ( isSetIterator ( value ) ) {
735
- braces = [ `[ ${ tag || 'Set Iterator' } ] {` , '}' ] ;
744
+ braces = setIteratorBraces ( 'Set' , tag ) ;
736
745
formatter = formatIterator ;
737
746
// Handle other regular objects again.
738
747
} else if ( keys . length === 0 ) {
@@ -754,7 +763,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
754
763
let output ;
755
764
const indentationLvl = ctx . indentationLvl ;
756
765
try {
757
- output = formatter ( ctx , value , recurseTimes , keys ) ;
766
+ output = formatter ( ctx , value , recurseTimes , keys , braces ) ;
758
767
for ( i = 0 ; i < keys . length ; i ++ ) {
759
768
output . push (
760
769
formatProperty ( ctx , value , recurseTimes , keys [ i ] , extrasType ) ) ;
@@ -1090,9 +1099,11 @@ function formatWeakMap(ctx, value, recurseTimes) {
1090
1099
return formatMapIterInner ( ctx , recurseTimes , entries , kWeak ) ;
1091
1100
}
1092
1101
1093
- function formatIterator ( ctx , value , recurseTimes ) {
1102
+ function formatIterator ( ctx , value , recurseTimes , keys , braces ) {
1094
1103
const [ entries , isKeyValue ] = previewEntries ( value , true ) ;
1095
1104
if ( isKeyValue ) {
1105
+ // Mark entry iterators as such.
1106
+ braces [ 0 ] = braces [ 0 ] . replace ( / I t e r a t o r ] { $ / , ' Entries] {' ) ;
1096
1107
return formatMapIterInner ( ctx , recurseTimes , entries , kMapEntries ) ;
1097
1108
}
1098
1109
0 commit comments