Skip to content

Commit

Permalink
feat(NODE-4767): Change abstract cursor return type (#3531)
Browse files Browse the repository at this point in the history
  • Loading branch information
W-A-James authored Jan 20, 2023
1 parent 056c86f commit 410ef30
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions etc/notes/CHANGES_5.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ The new minimum supported Node.js version is now 14.20.1.
The MongoClient option `promiseLibrary` along with the `Promise.set` export that allows specifying a custom promise library has been removed.
This allows the driver to adopt async/await syntax which has [performance benefits](https://v8.dev/blog/fast-async) over manual promise construction.

### Cursors now implement `AsyncGenerator` interface instead of `AsyncIterator`

All cursor types have been changed to implement `AsyncGenerator` instead of `AsyncIterator`.
This was done to make our typing more accurate.

### Cursor closes on exit of for await of loops

Cursors will now automatically close when exiting a for await of loop on the cursor itself.
Expand Down
2 changes: 1 addition & 1 deletion src/cursor/abstract_cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export abstract class AbstractCursor<
return bufferedDocs;
}

async *[Symbol.asyncIterator](): AsyncIterator<TSchema, void> {
async *[Symbol.asyncIterator](): AsyncGenerator<TSchema, void, void> {
if (this.closed) {
return;
}
Expand Down

0 comments on commit 410ef30

Please sign in to comment.