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