diff --git a/etc/notes/CHANGES_5.0.0.md b/etc/notes/CHANGES_5.0.0.md index f90cebc250e..0605d47fa6e 100644 --- a/etc/notes/CHANGES_5.0.0.md +++ b/etc/notes/CHANGES_5.0.0.md @@ -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. diff --git a/src/cursor/abstract_cursor.ts b/src/cursor/abstract_cursor.ts index b5fff69b303..a0662d6c308 100644 --- a/src/cursor/abstract_cursor.ts +++ b/src/cursor/abstract_cursor.ts @@ -288,7 +288,7 @@ export abstract class AbstractCursor< return bufferedDocs; } - async *[Symbol.asyncIterator](): AsyncIterator { + async *[Symbol.asyncIterator](): AsyncGenerator { if (this.closed) { return; }