@@ -681,7 +681,7 @@ export abstract class AbstractCursor<
681
681
* a significant refactor.
682
682
*/
683
683
[ kInit ] ( callback : Callback < TSchema | null > ) : void {
684
- this . _initialize ( this [ kSession ] , ( err , state ) => {
684
+ this . _initialize ( this [ kSession ] , ( error , state ) => {
685
685
if ( state ) {
686
686
const response = state . response ;
687
687
this [ kServer ] = state . server ;
@@ -713,8 +713,12 @@ export abstract class AbstractCursor<
713
713
// the cursor is now initialized, even if an error occurred or it is dead
714
714
this [ kInitialized ] = true ;
715
715
716
- if ( err || cursorIsDead ( this ) ) {
717
- return cleanupCursor ( this , { error : err } , ( ) => callback ( err , nextDocument ( this ) ) ) ;
716
+ if ( error ) {
717
+ return cleanupCursor ( this , { error } , ( ) => callback ( error , undefined ) ) ;
718
+ }
719
+
720
+ if ( cursorIsDead ( this ) ) {
721
+ return cleanupCursor ( this , undefined , ( ) => callback ( ) ) ;
718
722
}
719
723
720
724
callback ( ) ;
@@ -775,14 +779,8 @@ export function next<T>(
775
779
776
780
if ( cursorId == null ) {
777
781
// All cursors must operate within a session, one must be made implicitly if not explicitly provided
778
- cursor [ kInit ] ( ( err , value ) => {
782
+ cursor [ kInit ] ( err => {
779
783
if ( err ) return callback ( err ) ;
780
- // Intentional strict null check, because users can map cursors to falsey values.
781
- // We allow mapping to all values except for null.
782
- // eslint-disable-next-line no-restricted-syntax
783
- if ( value !== null ) {
784
- return callback ( undefined , value ) ;
785
- }
786
784
return next ( cursor , blocking , callback ) ;
787
785
} ) ;
788
786
0 commit comments