Skip to content

Commit 816b1b7

Browse files
baileympearsonnbbeeken
authored andcommitted
fix: strictly check for null in abstract cursor
1 parent 6809e37 commit 816b1b7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/cursor/abstract_cursor.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,10 @@ export abstract class AbstractCursor<
306306
while (true) {
307307
const document = await this.next();
308308

309-
if (document == null) {
309+
// Intentional strict null check, because users can map cursors to falsey values.
310+
// We allow mapping to all values except for null.
311+
// eslint-disable-next-line no-restricted-syntax
312+
if (document === null) {
310313
if (!this.closed) {
311314
const message =
312315
'Cursor returned a `null` document, but the cursor is not exhausted. Mapping documents to `null` is not supported in the cursor transform.';
@@ -777,7 +780,10 @@ export function next<T>(
777780
// All cursors must operate within a session, one must be made implicitly if not explicitly provided
778781
cursor[kInit]((err, value) => {
779782
if (err) return callback(err);
780-
if (value != null) {
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) {
781787
return callback(undefined, value);
782788
}
783789
return next(cursor, blocking, callback);

0 commit comments

Comments
 (0)