Skip to content

Commit 365ca27

Browse files
be explicit about arguments to next
1 parent 6e371ad commit 365ca27

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/cursor/abstract_cursor.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ export abstract class AbstractCursor<
361361
return true;
362362
}
363363

364-
const doc = await next<TSchema>(this, true, false);
364+
const doc = await next<TSchema>(this, { blocking: true, transform: false });
365365

366366
if (doc) {
367367
this[kDocuments].unshift(doc);
@@ -377,7 +377,7 @@ export abstract class AbstractCursor<
377377
throw new MongoCursorExhaustedError();
378378
}
379379

380-
return next(this, true);
380+
return next(this, { blocking: true, transform: true });
381381
}
382382

383383
/**
@@ -388,7 +388,7 @@ export abstract class AbstractCursor<
388388
throw new MongoCursorExhaustedError();
389389
}
390390

391-
return next(this, false);
391+
return next(this, { blocking: false, transform: true });
392392
}
393393

394394
/**
@@ -693,8 +693,13 @@ export abstract class AbstractCursor<
693693
*/
694694
async function next<T>(
695695
cursor: AbstractCursor<T>,
696-
blocking: boolean,
697-
transform = true
696+
{
697+
blocking,
698+
transform
699+
}: {
700+
blocking: boolean;
701+
transform: boolean;
702+
}
698703
): Promise<T | null> {
699704
const cursorId = cursor[kId];
700705
if (cursor.closed) {
@@ -723,7 +728,7 @@ async function next<T>(
723728
// All cursors must operate within a session, one must be made implicitly if not explicitly provided
724729
const init = promisify(cb => cursor[kInit](cb));
725730
await init();
726-
return next(cursor, blocking, transform);
731+
return next(cursor, { blocking, transform });
727732
}
728733

729734
if (cursorIsDead(cursor)) {
@@ -780,7 +785,7 @@ async function next<T>(
780785
return null;
781786
}
782787

783-
return next(cursor, blocking, transform);
788+
return next(cursor, { blocking, transform });
784789
}
785790

786791
function cursorIsDead(cursor: AbstractCursor): boolean {
@@ -904,7 +909,7 @@ class ReadableCursorStream extends Readable {
904909
}
905910

906911
private _readNext() {
907-
next(this._cursor, true).then(
912+
next(this._cursor, { blocking: true, transform: true }).then(
908913
result => {
909914
if (result == null) {
910915
this.push(null);

0 commit comments

Comments
 (0)