@@ -692,7 +692,7 @@ export abstract class AbstractCursor<
692
692
* a significant refactor.
693
693
*/
694
694
[ kInit ] ( callback : Callback < TSchema | null > ) : void {
695
- this . _initialize ( this [ kSession ] , ( err , state ) => {
695
+ this . _initialize ( this [ kSession ] , ( error , state ) => {
696
696
if ( state ) {
697
697
const response = state . response ;
698
698
this [ kServer ] = state . server ;
@@ -724,8 +724,12 @@ export abstract class AbstractCursor<
724
724
// the cursor is now initialized, even if an error occurred or it is dead
725
725
this [ kInitialized ] = true ;
726
726
727
- if ( err || cursorIsDead ( this ) ) {
728
- return cleanupCursor ( this , { error : err } , ( ) => callback ( err , nextDocument ( this ) ) ) ;
727
+ if ( error ) {
728
+ return cleanupCursor ( this , { error } , ( ) => callback ( error , undefined ) ) ;
729
+ }
730
+
731
+ if ( cursorIsDead ( this ) ) {
732
+ return cleanupCursor ( this , undefined , ( ) => callback ( ) ) ;
729
733
}
730
734
731
735
callback ( ) ;
@@ -778,14 +782,8 @@ export function next<T>(
778
782
779
783
if ( cursorId == null ) {
780
784
// All cursors must operate within a session, one must be made implicitly if not explicitly provided
781
- cursor [ kInit ] ( ( err , value ) => {
785
+ cursor [ kInit ] ( err => {
782
786
if ( err ) return callback ( err ) ;
783
- // Intentional strict null check, because users can map cursors to falsey values.
784
- // We allow mapping to all values except for null.
785
- // eslint-disable-next-line no-restricted-syntax
786
- if ( value !== null ) {
787
- return callback ( undefined , value ) ;
788
- }
789
787
return next ( cursor , blocking , callback ) ;
790
788
} ) ;
791
789
0 commit comments