@@ -1487,6 +1487,8 @@ function addNumericSeparatorEnd(integerString) {
14871487    `${ result } ${ integerString . slice ( i ) }  ` ; 
14881488} 
14891489
1490+ const  remainingText  =  ( remaining )  =>  `... ${ remaining }   more item${ remaining  >  1  ? 's'  : '' }  ` ; 
1491+ 
14901492function  formatNumber ( fn ,  number ,  numericSeparator )  { 
14911493  if  ( ! numericSeparator )  { 
14921494    // Format -0 as '-0'. Checking `number === -0` won't distinguish 0 from -0. 
@@ -1613,7 +1615,7 @@ function formatSpecialArray(ctx, value, recurseTimes, maxLength, output, i) {
16131615      output . push ( ctx . stylize ( message ,  'undefined' ) ) ; 
16141616    } 
16151617  }  else  if  ( remaining  >  0 )  { 
1616-     output . push ( `...  ${ remaining }  more item ${ remaining   >   1  ?  's'  :  '' } ` ) ; 
1618+     output . push ( remainingText ( remaining ) ) ; 
16171619  } 
16181620  return  output ; 
16191621} 
@@ -1650,7 +1652,7 @@ function formatArray(ctx, value, recurseTimes) {
16501652    output . push ( formatProperty ( ctx ,  value ,  recurseTimes ,  i ,  kArrayType ) ) ; 
16511653  } 
16521654  if  ( remaining  >  0 ) 
1653-     output . push ( `...  ${ remaining }  more item ${ remaining   >   1  ?  's'  :  '' } ` ) ; 
1655+     output . push ( remainingText ( remaining ) ) ; 
16541656  return  output ; 
16551657} 
16561658
@@ -1665,7 +1667,7 @@ function formatTypedArray(value, length, ctx, ignored, recurseTimes) {
16651667    output [ i ]  =  elementFormatter ( ctx . stylize ,  value [ i ] ,  ctx . numericSeparator ) ; 
16661668  } 
16671669  if  ( remaining  >  0 )  { 
1668-     output [ maxLength ]  =  `...  ${ remaining }  more item ${ remaining   >   1  ?  's'  :  '' } ` ; 
1670+     output [ maxLength ]  =  remainingText ( remaining ) ; 
16691671  } 
16701672  if  ( ctx . showHidden )  { 
16711673    // .buffer goes last, it's not a primitive like the others. 
@@ -1687,22 +1689,40 @@ function formatTypedArray(value, length, ctx, ignored, recurseTimes) {
16871689} 
16881690
16891691function  formatSet ( value ,  ctx ,  ignored ,  recurseTimes )  { 
1692+   const  length  =  value . size ; 
1693+   const  maxLength  =  MathMin ( MathMax ( 0 ,  ctx . maxArrayLength ) ,  length ) ; 
1694+   const  remaining  =  length  -  maxLength ; 
16901695  const  output  =  [ ] ; 
16911696  ctx . indentationLvl  +=  2 ; 
1697+   let  i  =  0 ; 
16921698  for  ( const  v  of  value )  { 
1699+     if  ( i  >=  maxLength )  break ; 
16931700    ArrayPrototypePush ( output ,  formatValue ( ctx ,  v ,  recurseTimes ) ) ; 
1701+     i ++ ; 
1702+   } 
1703+   if  ( remaining  >  0 )  { 
1704+     ArrayPrototypePush ( output ,  remainingText ( remaining ) ) ; 
16941705  } 
16951706  ctx . indentationLvl  -=  2 ; 
16961707  return  output ; 
16971708} 
16981709
16991710function  formatMap ( value ,  ctx ,  ignored ,  recurseTimes )  { 
1711+   const  length  =  value . size ; 
1712+   const  maxLength  =  MathMin ( MathMax ( 0 ,  ctx . maxArrayLength ) ,  length ) ; 
1713+   const  remaining  =  length  -  maxLength ; 
17001714  const  output  =  [ ] ; 
17011715  ctx . indentationLvl  +=  2 ; 
1716+   let  i  =  0 ; 
17021717  for  ( const  {  0 : k ,  1 : v  }  of  value )  { 
1718+     if  ( i  >=  maxLength )  break ; 
17031719    output . push ( 
17041720      `${ formatValue ( ctx ,  k ,  recurseTimes ) }   => ${ formatValue ( ctx ,  v ,  recurseTimes ) }  ` 
17051721    ) ; 
1722+     i ++ ; 
1723+   } 
1724+   if  ( remaining  >  0 )  { 
1725+     ArrayPrototypePush ( output ,  remainingText ( remaining ) ) ; 
17061726  } 
17071727  ctx . indentationLvl  -=  2 ; 
17081728  return  output ; 
@@ -1725,8 +1745,7 @@ function formatSetIterInner(ctx, recurseTimes, entries, state) {
17251745  } 
17261746  const  remaining  =  entries . length  -  maxLength ; 
17271747  if  ( remaining  >  0 )  { 
1728-     ArrayPrototypePush ( output , 
1729-                        `... ${ remaining }   more item${ remaining  >  1  ? 's'  : '' }  ` ) ; 
1748+     ArrayPrototypePush ( output ,  remainingText ( remaining ) ) ; 
17301749  } 
17311750  return  output ; 
17321751} 
@@ -1764,7 +1783,7 @@ function formatMapIterInner(ctx, recurseTimes, entries, state) {
17641783  } 
17651784  ctx . indentationLvl  -=  2 ; 
17661785  if  ( remaining  >  0 )  { 
1767-     output . push ( `...  ${ remaining }  more item ${ remaining   >   1  ?  's'  :  '' } ` ) ; 
1786+     output . push ( remainingText ( remaining ) ) ; 
17681787  } 
17691788  return  output ; 
17701789} 
0 commit comments