@@ -389,7 +389,7 @@ export abstract class AbstractCursor<
389
389
return true ;
390
390
}
391
391
392
- return await next ( this , { blocking : true , transform : false , hasNext : true } ) ;
392
+ return await next ( this , { blocking : true , transform : false , shift : false } ) ;
393
393
}
394
394
395
395
/** Get the next available document from the cursor, returns null if no more documents are available. */
@@ -398,7 +398,7 @@ export abstract class AbstractCursor<
398
398
throw new MongoCursorExhaustedError ( ) ;
399
399
}
400
400
401
- return await next ( this , { blocking : true , transform : true , hasNext : false } ) ;
401
+ return await next ( this , { blocking : true , transform : true , shift : true } ) ;
402
402
}
403
403
404
404
/**
@@ -409,7 +409,7 @@ export abstract class AbstractCursor<
409
409
throw new MongoCursorExhaustedError ( ) ;
410
410
}
411
411
412
- return await next ( this , { blocking : false , transform : true , hasNext : false } ) ;
412
+ return await next ( this , { blocking : false , transform : true , shift : true } ) ;
413
413
}
414
414
415
415
/**
@@ -719,11 +719,11 @@ async function next<T>(
719
719
{
720
720
blocking,
721
721
transform,
722
- hasNext
722
+ shift
723
723
} : {
724
724
blocking : boolean ;
725
725
transform : boolean ;
726
- hasNext : true ;
726
+ shift : false ;
727
727
}
728
728
) : Promise < boolean > ;
729
729
@@ -732,11 +732,11 @@ async function next<T>(
732
732
{
733
733
blocking,
734
734
transform,
735
- hasNext
735
+ shift
736
736
} : {
737
737
blocking : boolean ;
738
738
transform : boolean ;
739
- hasNext : false ;
739
+ shift : true ;
740
740
}
741
741
) : Promise < T | null > ;
742
742
@@ -745,15 +745,15 @@ async function next<T>(
745
745
{
746
746
blocking,
747
747
transform,
748
- hasNext
748
+ shift
749
749
} : {
750
750
blocking : boolean ;
751
751
transform : boolean ;
752
- hasNext : boolean ;
752
+ shift : boolean ;
753
753
}
754
754
) : Promise < boolean | T | null > {
755
755
if ( cursor . closed ) {
756
- if ( hasNext ) return false ;
756
+ if ( ! shift ) return false ;
757
757
return null ;
758
758
}
759
759
@@ -764,7 +764,7 @@ async function next<T>(
764
764
}
765
765
766
766
if ( cursor [ kDocuments ] . length !== 0 ) {
767
- if ( hasNext ) return true ;
767
+ if ( ! shift ) return true ;
768
768
const doc = cursor [ kDocuments ] . shift ( cursor [ kOptions ] ) ;
769
769
770
770
if ( doc != null && transform && cursor [ kTransform ] ) {
@@ -789,7 +789,7 @@ async function next<T>(
789
789
// cleanupCursor should never throw, but if it does it indicates a bug in the driver
790
790
// and we should surface the error
791
791
await cleanupCursor ( cursor , { } ) ;
792
- if ( hasNext ) return false ;
792
+ if ( ! shift ) return false ;
793
793
return null ;
794
794
}
795
795
@@ -834,12 +834,12 @@ async function next<T>(
834
834
}
835
835
836
836
if ( cursor [ kDocuments ] . length === 0 && blocking === false ) {
837
- if ( hasNext ) return false ;
837
+ if ( ! shift ) return false ;
838
838
return null ;
839
839
}
840
840
} while ( ! cursor . isDead || cursor [ kDocuments ] . length !== 0 ) ;
841
841
842
- if ( hasNext ) return false ;
842
+ if ( ! shift ) return false ;
843
843
return null ;
844
844
}
845
845
@@ -961,7 +961,7 @@ class ReadableCursorStream extends Readable {
961
961
962
962
private _readNext ( ) {
963
963
// eslint-disable-next-line github/no-then
964
- next ( this . _cursor , { blocking : true , transform : true , hasNext : false } ) . then (
964
+ next ( this . _cursor , { blocking : true , transform : true , shift : false } ) . then (
965
965
result => {
966
966
if ( result == null ) {
967
967
this . push ( null ) ;
0 commit comments