Skip to content

Commit

Permalink
refactor: don't use null for missing callback values
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Dec 30, 2019
1 parent 10f07b0 commit 4b2b81f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/core/connection/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@ function performInitialHandshake(conn, options, _callback) {
const start = new Date().getTime();
runCommand(conn, 'admin.$cmd', handshakeDoc, options, (err, ismaster) => {
if (err) {
callback(err, null);
callback(err);
return;
}

if (ismaster.ok === 0) {
callback(new MongoError(ismaster), null);
callback(new MongoError(ismaster));
return;
}

const supportedServerErr = checkSupportedServer(ismaster, options);
if (supportedServerErr) {
callback(supportedServerErr, null);
callback(supportedServerErr);
return;
}

Expand Down Expand Up @@ -159,7 +159,7 @@ function performInitialHandshake(conn, options, _callback) {
return;
}

callback(null, conn);
callback(undefined, conn);
});
}

Expand Down Expand Up @@ -350,7 +350,7 @@ function runCommand(conn, ns, command, options, callback) {
// ignore all future errors
conn.on('error', noop);

_callback(err, null);
_callback(err);
}

function messageHandler(msg) {
Expand All @@ -363,7 +363,7 @@ function runCommand(conn, ns, command, options, callback) {
conn.removeListener('message', messageHandler);

msg.parse({ promoteValues: true });
_callback(null, msg.documents[0]);
_callback(undefined, msg.documents[0]);
}

conn.setSocketTimeout(socketTimeout);
Expand All @@ -382,7 +382,7 @@ function authenticate(conn, credentials, callback) {
const provider = AUTH_PROVIDERS[mechanism];
provider.auth(runCommand, [conn], credentials, err => {
if (err) return callback(err);
callback(null, conn);
callback(undefined, conn);
});
}

Expand Down

0 comments on commit 4b2b81f

Please sign in to comment.