Skip to content

Commit 33dd1e0

Browse files
use ternarys
1 parent b27f44a commit 33dd1e0

File tree

1 file changed

+24
-10
lines changed

1 file changed

+24
-10
lines changed

src/legacy_wrappers/cursors.js

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

28-
explain(_verbosity, _options, _callback) {
29-
const argumentsArray = Array.from(arguments);
30-
const callback = argumentsArray.find(argument => typeof argument === 'function');
31-
callback != null && argumentsArray.pop();
32-
return maybeCallback(super.explain(...argumentsArray), callback);
28+
explain(verbosity, options, callback) {
29+
callback =
30+
typeof callback === 'function'
31+
? callback
32+
: typeof options === 'function'
33+
? options
34+
: typeof verbosity === 'function'
35+
? verbosity
36+
: undefined;
37+
options = typeof options !== 'function' ? options : undefined;
38+
verbosity = typeof verbosity !== 'function' ? verbosity : undefined;
39+
return maybeCallback(super.explain(...arguments), callback);
3340
}
3441

3542
close(options, callback) {
@@ -176,11 +183,18 @@ module.exports.makeLegacyAggregationCursor = function (baseClass) {
176183
}
177184

178185
class LegacyAggregationCursor extends baseClass {
179-
explain(_verbosity, _options, _callback) {
180-
const argumentsArray = Array.from(arguments);
181-
const callback = argumentsArray.find(argument => typeof argument === 'function');
182-
callback != null && argumentsArray.pop();
183-
return maybeCallback(super.explain(...argumentsArray), callback);
186+
explain(verbosity, options, callback) {
187+
callback =
188+
typeof callback === 'function'
189+
? callback
190+
: typeof options === 'function'
191+
? options
192+
: typeof verbosity === 'function'
193+
? verbosity
194+
: undefined;
195+
options = typeof options !== 'function' ? options : undefined;
196+
verbosity = typeof verbosity !== 'function' ? verbosity : undefined;
197+
return maybeCallback(super.explain(...arguments), callback);
184198
}
185199

186200
close(options, callback) {

0 commit comments

Comments
 (0)