Skip to content

Commit 410ef30

Browse files
authored
feat(NODE-4767): Change abstract cursor return type (#3531)
1 parent 056c86f commit 410ef30

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

etc/notes/CHANGES_5.0.0.md

+5
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ The new minimum supported Node.js version is now 14.20.1.
192192
The MongoClient option `promiseLibrary` along with the `Promise.set` export that allows specifying a custom promise library has been removed.
193193
This allows the driver to adopt async/await syntax which has [performance benefits](https://v8.dev/blog/fast-async) over manual promise construction.
194194

195+
### Cursors now implement `AsyncGenerator` interface instead of `AsyncIterator`
196+
197+
All cursor types have been changed to implement `AsyncGenerator` instead of `AsyncIterator`.
198+
This was done to make our typing more accurate.
199+
195200
### Cursor closes on exit of for await of loops
196201

197202
Cursors will now automatically close when exiting a for await of loop on the cursor itself.

src/cursor/abstract_cursor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ export abstract class AbstractCursor<
288288
return bufferedDocs;
289289
}
290290

291-
async *[Symbol.asyncIterator](): AsyncIterator<TSchema, void> {
291+
async *[Symbol.asyncIterator](): AsyncGenerator<TSchema, void, void> {
292292
if (this.closed) {
293293
return;
294294
}

0 commit comments

Comments
 (0)