Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dns: make var to const if possible #13797

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions lib/dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function onlookupall(err, addresses) {
return this.callback(errnoException(err, 'getaddrinfo', this.hostname));
}

var family = this.family;
const family = this.family;
for (var i = 0; i < addresses.length; i++) {
const addr = addresses[i];
addresses[i] = {
Expand Down Expand Up @@ -159,7 +159,7 @@ function lookup(hostname, options, callback) {
return {};
}

var matchedFamily = isIP(hostname);
const matchedFamily = isIP(hostname);
if (matchedFamily) {
if (all) {
process.nextTick(
Expand All @@ -170,13 +170,13 @@ function lookup(hostname, options, callback) {
return {};
}

var req = new GetAddrInfoReqWrap();
const req = new GetAddrInfoReqWrap();
req.callback = callback;
req.family = family;
req.hostname = hostname;
req.oncomplete = all ? onlookupall : onlookup;

var err = cares.getaddrinfo(req, hostname, family, hints);
const err = cares.getaddrinfo(req, hostname, family, hints);
if (err) {
process.nextTick(callback, errnoException(err, 'getaddrinfo', hostname));
return {};
Expand Down Expand Up @@ -212,13 +212,13 @@ function lookupService(host, port, callback) {

port = +port;

var req = new GetNameInfoReqWrap();
const req = new GetNameInfoReqWrap();
req.callback = callback;
req.host = host;
req.port = port;
req.oncomplete = onlookupservice;

var err = cares.getnameinfo(req, host, port);
const err = cares.getnameinfo(req, host, port);
if (err) throw errnoException(err, 'getnameinfo', host);
return req;
}
Expand All @@ -239,7 +239,7 @@ function onresolve(err, result, ttls) {


function resolver(bindingName) {
var binding = cares[bindingName];
const binding = cares[bindingName];

return function query(name, /* options, */ callback) {
var options;
Expand All @@ -254,20 +254,20 @@ function resolver(bindingName) {
throw new Error('"callback" argument must be a function');
}

var req = new QueryReqWrap();
const req = new QueryReqWrap();
req.bindingName = bindingName;
req.callback = callback;
req.hostname = name;
req.oncomplete = onresolve;
req.ttl = !!(options && options.ttl);
var err = binding(req, name);
const err = binding(req, name);
if (err) throw errnoException(err, bindingName);
return req;
};
}


var resolveMap = Object.create(null);
const resolveMap = Object.create(null);
resolveMap.ANY = resolver('queryAny');
resolveMap.A = resolver('queryA');
resolveMap.AAAA = resolver('queryAaaa');
Expand Down Expand Up @@ -341,7 +341,7 @@ function setServers(servers) {
// reset the servers to the old servers, because ares probably unset them
cares.setServers(orig.join(','));

var err = cares.strerror(errorNumber);
const err = cares.strerror(errorNumber);
throw new Error(`c-ares failed to set servers: "${err}" [${servers}]`);
}
}
Expand Down