Skip to content

Commit 4143a75

Browse files
test
1 parent 2702b72 commit 4143a75

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

src/legacy_wrappers/cursors.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,9 @@ module.exports.makeLegacyFindCursor = function (baseClass) {
2525
return maybeCallback(super.count(options), callback);
2626
}
2727

28-
explain(verbosity, callback) {
29-
callback =
30-
typeof callback === 'function'
31-
? callback
32-
: typeof verbosity === 'function'
33-
? verbosity
34-
: undefined;
35-
verbosity = typeof verbosity !== 'function' ? verbosity : undefined;
36-
return maybeCallback(super.explain(verbosity), callback);
28+
explain(_verbosity, _options, _callback) {
29+
const callback = Array.from(arguments).find(argument => typeof argument === 'function');
30+
return maybeCallback(super.explain(...arguments), callback);
3731
}
3832

3933
close(options, callback) {
@@ -180,15 +174,9 @@ module.exports.makeLegacyAggregationCursor = function (baseClass) {
180174
}
181175

182176
class LegacyAggregationCursor extends baseClass {
183-
explain(verbosity, callback) {
184-
callback =
185-
typeof callback === 'function'
186-
? callback
187-
: typeof verbosity === 'function'
188-
? verbosity
189-
: undefined;
190-
verbosity = typeof verbosity !== 'function' ? verbosity : undefined;
191-
return maybeCallback(super.explain(verbosity), callback);
177+
explain(_verbosity, _options, _callback) {
178+
const callback = Array.from(arguments).find(argument => typeof argument === 'function');
179+
return maybeCallback(super.explain(...arguments), callback);
192180
}
193181

194182
close(options, callback) {

test/tools/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const api = [
3838
{ className: 'Admin', method: 'serverStatus', returnType: 'Promise<Document>' },
3939
{ className: 'Admin', method: 'validateCollection', returnType: 'Promise<Document>' },
4040

41-
{ className: 'AggregationCursor', method: 'explain', returnType: 'Promise<Document>' },
41+
{ className: 'AggregationCursor', method: 'explain', returnType: 'Promise<Document>', possibleCallbackPositions: [1, 2, 3] },
4242
{ className: 'AggregationCursor', method: 'clone', returnType: 'AggregationCursor', notAsync: true },
4343

4444
{ className: 'FindCursor', method: 'clone', returnType: 'FindCursor', notAsync: true },
@@ -115,7 +115,7 @@ const api = [
115115
{ className: 'Db', method: 'watch', returnType: 'ChangeStream', notAsync: true },
116116

117117
{ className: 'FindCursor', method: 'count', returnType: 'Promise<number>' },
118-
{ className: 'FindCursor', method: 'explain', returnType: 'Promise<Document>' },
118+
{ className: 'FindCursor', method: 'explain', returnType: 'Promise<Document>', possibleCallbackPositions: [1,2,3] },
119119

120120
{ className: 'GridFSBucket', method: 'delete', returnType: 'Promise<void>', possibleCallbackPositions: [1, 2] },
121121
{ className: 'GridFSBucket', method: 'drop', returnType: 'Promise<void>', possibleCallbackPositions: [1, 2] },

0 commit comments

Comments
 (0)