Skip to content

Commit 8ef1fe6

Browse files
fix: strictly check for null in abstract cursor
1 parent ec9c6fb commit 8ef1fe6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/cursor/abstract_cursor.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,10 @@ export abstract class AbstractCursor<
295295
while (true) {
296296
const document = await this.next();
297297

298-
if (document == null) {
298+
// Intentional strict null check, because users can map cursors to falsey values.
299+
// We allow mapping to all values except for null.
300+
// eslint-disable-next-line no-restricted-syntax
301+
if (document === null) {
299302
if (!this.closed) {
300303
const message =
301304
'Cursor returned a `null` document, but the cursor is not exhausted. Mapping documents to `null` is not supported in the cursor transform.';
@@ -774,7 +777,10 @@ export function next<T>(
774777
// All cursors must operate within a session, one must be made implicitly if not explicitly provided
775778
cursor[kInit]((err, value) => {
776779
if (err) return callback(err);
777-
if (value != null) {
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) {
778784
return callback(undefined, value);
779785
}
780786
return next(cursor, blocking, callback);

0 commit comments

Comments
 (0)