@@ -361,7 +361,7 @@ export abstract class AbstractCursor<
361
361
return true ;
362
362
}
363
363
364
- const doc = await next < TSchema > ( this , true , false ) ;
364
+ const doc = await next < TSchema > ( this , { blocking : true , transform : false } ) ;
365
365
366
366
if ( doc ) {
367
367
this [ kDocuments ] . unshift ( doc ) ;
@@ -377,7 +377,7 @@ export abstract class AbstractCursor<
377
377
throw new MongoCursorExhaustedError ( ) ;
378
378
}
379
379
380
- return next ( this , true ) ;
380
+ return next ( this , { blocking : true , transform : true } ) ;
381
381
}
382
382
383
383
/**
@@ -388,7 +388,7 @@ export abstract class AbstractCursor<
388
388
throw new MongoCursorExhaustedError ( ) ;
389
389
}
390
390
391
- return next ( this , false ) ;
391
+ return next ( this , { blocking : false , transform : true } ) ;
392
392
}
393
393
394
394
/**
@@ -693,8 +693,13 @@ export abstract class AbstractCursor<
693
693
*/
694
694
async function next < T > (
695
695
cursor : AbstractCursor < T > ,
696
- blocking : boolean ,
697
- transform = true
696
+ {
697
+ blocking,
698
+ transform
699
+ } : {
700
+ blocking : boolean ;
701
+ transform : boolean ;
702
+ }
698
703
) : Promise < T | null > {
699
704
const cursorId = cursor [ kId ] ;
700
705
if ( cursor . closed ) {
@@ -723,7 +728,7 @@ async function next<T>(
723
728
// All cursors must operate within a session, one must be made implicitly if not explicitly provided
724
729
const init = promisify ( cb => cursor [ kInit ] ( cb ) ) ;
725
730
await init ( ) ;
726
- return next ( cursor , blocking , transform ) ;
731
+ return next ( cursor , { blocking, transform } ) ;
727
732
}
728
733
729
734
if ( cursorIsDead ( cursor ) ) {
@@ -780,7 +785,7 @@ async function next<T>(
780
785
return null ;
781
786
}
782
787
783
- return next ( cursor , blocking , transform ) ;
788
+ return next ( cursor , { blocking, transform } ) ;
784
789
}
785
790
786
791
function cursorIsDead ( cursor : AbstractCursor ) : boolean {
@@ -904,7 +909,7 @@ class ReadableCursorStream extends Readable {
904
909
}
905
910
906
911
private _readNext ( ) {
907
- next ( this . _cursor , true ) . then (
912
+ next ( this . _cursor , { blocking : true , transform : true } ) . then (
908
913
result => {
909
914
if ( result == null ) {
910
915
this . push ( null ) ;
0 commit comments