@@ -540,6 +540,15 @@ function formatValue(ctx, value, recurseTimes, typedArray) {
540540 return formatRaw ( ctx , value , recurseTimes , typedArray ) ;
541541}
542542
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+
543552function formatRaw ( ctx , value , recurseTimes , typedArray ) {
544553 let keys ;
545554
@@ -594,11 +603,11 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
594603 extrasType = kArrayExtrasType ;
595604 } else if ( isMapIterator ( value ) ) {
596605 keys = getKeys ( value , ctx . showHidden ) ;
597- braces = [ `[ ${ tag } ] {` , '}' ] ;
606+ braces = setIteratorBraces ( 'Map' , tag ) ;
598607 formatter = formatIterator ;
599608 } else if ( isSetIterator ( value ) ) {
600609 keys = getKeys ( value , ctx . showHidden ) ;
601- braces = [ `[ ${ tag } ] {` , '}' ] ;
610+ braces = setIteratorBraces ( 'Set' , tag ) ;
602611 formatter = formatIterator ;
603612 } else {
604613 noIterator = true ;
@@ -730,10 +739,10 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
730739 }
731740 }
732741 if ( isMapIterator ( value ) ) {
733- braces = [ `[ ${ tag || 'Map Iterator' } ] {` , '}' ] ;
742+ braces = setIteratorBraces ( 'Map' , tag ) ;
734743 formatter = formatIterator ;
735744 } else if ( isSetIterator ( value ) ) {
736- braces = [ `[ ${ tag || 'Set Iterator' } ] {` , '}' ] ;
745+ braces = setIteratorBraces ( 'Set' , tag ) ;
737746 formatter = formatIterator ;
738747 // Handle other regular objects again.
739748 } else if ( keys . length === 0 ) {
@@ -755,7 +764,7 @@ function formatRaw(ctx, value, recurseTimes, typedArray) {
755764 let output ;
756765 const indentationLvl = ctx . indentationLvl ;
757766 try {
758- output = formatter ( ctx , value , recurseTimes , keys ) ;
767+ output = formatter ( ctx , value , recurseTimes , keys , braces ) ;
759768 for ( i = 0 ; i < keys . length ; i ++ ) {
760769 output . push (
761770 formatProperty ( ctx , value , recurseTimes , keys [ i ] , extrasType ) ) ;
@@ -1091,9 +1100,11 @@ function formatWeakMap(ctx, value, recurseTimes) {
10911100 return formatMapIterInner ( ctx , recurseTimes , entries , kWeak ) ;
10921101}
10931102
1094- function formatIterator ( ctx , value , recurseTimes ) {
1103+ function formatIterator ( ctx , value , recurseTimes , keys , braces ) {
10951104 const [ entries , isKeyValue ] = previewEntries ( value , true ) ;
10961105 if ( isKeyValue ) {
1106+ // Mark entry iterators as such.
1107+ braces [ 0 ] = braces [ 0 ] . replace ( / I t e r a t o r ] { $ / , ' Entries] {' ) ;
10971108 return formatMapIterInner ( ctx , recurseTimes , entries , kMapEntries ) ;
10981109 }
10991110
0 commit comments