Skip to content

Commit ea365c1

Browse files
committed
fix: rename hasNext
1 parent 0902172 commit ea365c1

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/cursor/abstract_cursor.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ export abstract class AbstractCursor<
389389
return true;
390390
}
391391

392-
return await next(this, { blocking: true, transform: false, hasNext: true });
392+
return await next(this, { blocking: true, transform: false, shift: false });
393393
}
394394

395395
/** Get the next available document from the cursor, returns null if no more documents are available. */
@@ -398,7 +398,7 @@ export abstract class AbstractCursor<
398398
throw new MongoCursorExhaustedError();
399399
}
400400

401-
return await next(this, { blocking: true, transform: true, hasNext: false });
401+
return await next(this, { blocking: true, transform: true, shift: true });
402402
}
403403

404404
/**
@@ -409,7 +409,7 @@ export abstract class AbstractCursor<
409409
throw new MongoCursorExhaustedError();
410410
}
411411

412-
return await next(this, { blocking: false, transform: true, hasNext: false });
412+
return await next(this, { blocking: false, transform: true, shift: true });
413413
}
414414

415415
/**
@@ -719,11 +719,11 @@ async function next<T>(
719719
{
720720
blocking,
721721
transform,
722-
hasNext
722+
shift
723723
}: {
724724
blocking: boolean;
725725
transform: boolean;
726-
hasNext: true;
726+
shift: false;
727727
}
728728
): Promise<boolean>;
729729

@@ -732,11 +732,11 @@ async function next<T>(
732732
{
733733
blocking,
734734
transform,
735-
hasNext
735+
shift
736736
}: {
737737
blocking: boolean;
738738
transform: boolean;
739-
hasNext: false;
739+
shift: true;
740740
}
741741
): Promise<T | null>;
742742

@@ -745,15 +745,15 @@ async function next<T>(
745745
{
746746
blocking,
747747
transform,
748-
hasNext
748+
shift
749749
}: {
750750
blocking: boolean;
751751
transform: boolean;
752-
hasNext: boolean;
752+
shift: boolean;
753753
}
754754
): Promise<boolean | T | null> {
755755
if (cursor.closed) {
756-
if (hasNext) return false;
756+
if (!shift) return false;
757757
return null;
758758
}
759759

@@ -764,7 +764,7 @@ async function next<T>(
764764
}
765765

766766
if (cursor[kDocuments].length !== 0) {
767-
if (hasNext) return true;
767+
if (!shift) return true;
768768
const doc = cursor[kDocuments].shift(cursor[kOptions]);
769769

770770
if (doc != null && transform && cursor[kTransform]) {
@@ -789,7 +789,7 @@ async function next<T>(
789789
// cleanupCursor should never throw, but if it does it indicates a bug in the driver
790790
// and we should surface the error
791791
await cleanupCursor(cursor, {});
792-
if (hasNext) return false;
792+
if (!shift) return false;
793793
return null;
794794
}
795795

@@ -834,12 +834,12 @@ async function next<T>(
834834
}
835835

836836
if (cursor[kDocuments].length === 0 && blocking === false) {
837-
if (hasNext) return false;
837+
if (!shift) return false;
838838
return null;
839839
}
840840
} while (!cursor.isDead || cursor[kDocuments].length !== 0);
841841

842-
if (hasNext) return false;
842+
if (!shift) return false;
843843
return null;
844844
}
845845

@@ -961,7 +961,7 @@ class ReadableCursorStream extends Readable {
961961

962962
private _readNext() {
963963
// 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(
965965
result => {
966966
if (result == null) {
967967
this.push(null);

0 commit comments

Comments
 (0)