Skip to content

Commit 848478a

Browse files
committed
refactor: remove unnecessary async iterator checks
1 parent 6ec3b48 commit 848478a

File tree

2 files changed

+8
-26
lines changed

2 files changed

+8
-26
lines changed

lib/aggregate.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,24 +1139,15 @@ Aggregate.prototype.finally = function(onFinally) {
11391139
* console.log(doc.name);
11401140
* }
11411141
*
1142-
* Node.js 10.x supports async iterators natively without any flags. You can
1143-
* enable async iterators in Node.js 8.x using the [`--harmony_async_iteration` flag](https://github.com/tc39/proposal-async-iteration/issues/117#issuecomment-346695187).
1144-
*
1145-
* **Note:** This function is not set if `Symbol.asyncIterator` is undefined. If
1146-
* `Symbol.asyncIterator` is undefined, that means your Node.js version does not
1147-
* support async iterators.
1148-
*
11491142
* @method [Symbol.asyncIterator]
11501143
* @memberOf Aggregate
11511144
* @instance
11521145
* @api public
11531146
*/
11541147

1155-
if (Symbol.asyncIterator != null) {
1156-
Aggregate.prototype[Symbol.asyncIterator] = function() {
1157-
return this.cursor({ useMongooseAggCursor: true }).transformNull()._transformForAsyncIterator();
1158-
};
1159-
}
1148+
Aggregate.prototype[Symbol.asyncIterator] = function() {
1149+
return this.cursor({ useMongooseAggCursor: true }).transformNull()._transformForAsyncIterator();
1150+
};
11601151

11611152
/*!
11621153
* Helpers

lib/query.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5406,26 +5406,17 @@ Query.prototype.nearSphere = function() {
54065406
* console.log(doc.name);
54075407
* }
54085408
*
5409-
* Node.js 10.x supports async iterators natively without any flags. You can
5410-
* enable async iterators in Node.js 8.x using the [`--harmony_async_iteration` flag](https://github.com/tc39/proposal-async-iteration/issues/117#issuecomment-346695187).
5411-
*
5412-
* **Note:** This function is not if `Symbol.asyncIterator` is undefined. If
5413-
* `Symbol.asyncIterator` is undefined, that means your Node.js version does not
5414-
* support async iterators.
5415-
*
54165409
* @method [Symbol.asyncIterator]
54175410
* @memberOf Query
54185411
* @instance
54195412
* @api public
54205413
*/
54215414

5422-
if (Symbol.asyncIterator != null) {
5423-
Query.prototype[Symbol.asyncIterator] = function queryAsyncIterator() {
5424-
// Set so QueryCursor knows it should transform results for async iterators into `{ value, done }` syntax
5425-
this._mongooseOptions._asyncIterator = true;
5426-
return this.cursor();
5427-
};
5428-
}
5415+
Query.prototype[Symbol.asyncIterator] = function queryAsyncIterator() {
5416+
// Set so QueryCursor knows it should transform results for async iterators into `{ value, done }` syntax
5417+
this._mongooseOptions._asyncIterator = true;
5418+
return this.cursor();
5419+
};
54295420

54305421
/**
54315422
* Specifies a `$polygon` condition

0 commit comments

Comments
 (0)