@@ -682,11 +682,12 @@ function formatObject(ctx, value, recurseTimes, visibleKeys, keys) {
682682
683683
684684function  formatArray ( ctx ,  value ,  recurseTimes ,  visibleKeys ,  keys )  { 
685+   const  maxLength  =  Math . min ( Math . max ( 0 ,  ctx . maxArrayLength ) ,  value . length ) ; 
685686  var  output  =  [ ] ; 
686687  let  visibleLength  =  0 ; 
687688  let  index  =  0 ; 
688689  for  ( const  elem  of  keys )  { 
689-     if  ( visibleLength  ===  ctx . maxArrayLength ) 
690+     if  ( visibleLength  ===  maxLength ) 
690691      break ; 
691692    // Symbols might have been added to the keys 
692693    if  ( typeof  elem  !==  'string' ) 
@@ -701,15 +702,15 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
701702      const  message  =  `<${ emptyItems } ${ ending }  ; 
702703      output . push ( ctx . stylize ( message ,  'undefined' ) ) ; 
703704      index  =  i ; 
704-       if  ( ++ visibleLength  ===  ctx . maxArrayLength ) 
705+       if  ( ++ visibleLength  ===  maxLength ) 
705706        break ; 
706707    } 
707708    output . push ( formatProperty ( ctx ,  value ,  recurseTimes ,  visibleKeys , 
708709                               elem ,  true ) ) ; 
709710    visibleLength ++ ; 
710711    index ++ ; 
711712  } 
712-   if  ( index  <  value . length  &&  visibleLength  !==  ctx . maxArrayLength )  { 
713+   if  ( index  <  value . length  &&  visibleLength  !==  maxLength )  { 
713714    const  len  =  value . length  -  index ; 
714715    const  ending  =  len  >  1  ? 's'  : '' ; 
715716    const  message  =  `<${ len } ${ ending }  ; 
0 commit comments