File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -686,7 +686,7 @@ export abstract class AbstractCursor<
686686  async  toArray ( ) : Promise < TSchema [ ] >  { 
687687    this . signal ?. throwIfAborted ( ) ; 
688688
689-     let  array : TSchema [ ]  =  [ ] ; 
689+     const  array : TSchema [ ]  =  [ ] ; 
690690    // at the end of the loop (since readBufferedDocuments is called) the buffer will be empty 
691691    // then, the 'await of' syntax will run a getMore call 
692692    for  await  ( const  document  of  this )  { 
@@ -699,7 +699,9 @@ export abstract class AbstractCursor<
699699      }  else  { 
700700        // Note: previous versions of this logic used `array.push(...)`, which adds each item 
701701        // to the callstack.  For large arrays, this can exceed the maximum call size. 
702-         array  =  array . concat ( docs ) ; 
702+         for  ( const  doc  of  docs )  { 
703+           array . push ( doc ) ; 
704+         } 
703705      } 
704706    } 
705707    return  array ; 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments