Skip to content

Commit

Permalink
lib: prepare files for no-var lint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Trott committed Apr 2, 2022
1 parent fb092b4 commit ff14db9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
8 changes: 2 additions & 6 deletions lib/internal/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,7 @@ function emitInitNative(asyncId, type, triggerAsyncId, resource) {
resource = lookupPublicResource(resource);
// Use a single try/catch for all hooks to avoid setting up one per iteration.
try {
// Using var here instead of let because "for (var ...)" is faster than let.
// Refs: https://github.com/nodejs/node/pull/30380#issuecomment-552948364
for (var i = 0; i < active_hooks.array.length; i++) {
for (let i = 0; i < active_hooks.array.length; i++) {
if (typeof active_hooks.array[i][init_symbol] === 'function') {
active_hooks.array[i][init_symbol](
asyncId, type, triggerAsyncId,
Expand Down Expand Up @@ -226,9 +224,7 @@ function emitHook(symbol, asyncId) {
// Use a single try/catch for all hook to avoid setting up one per
// iteration.
try {
// Using var here instead of let because "for (var ...)" is faster than let.
// Refs: https://github.com/nodejs/node/pull/30380#issuecomment-552948364
for (var i = 0; i < active_hooks.array.length; i++) {
for (let i = 0; i < active_hooks.array.length; i++) {
if (typeof active_hooks.array[i][symbol] === 'function') {
active_hooks.array[i][symbol](asyncId);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/crypto/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function lazyRequire(name) {
return ret;
}

var defaultEncoding = 'buffer';
let defaultEncoding = 'buffer';

function setDefaultEncoding(val) {
defaultEncoding = val;
Expand Down
12 changes: 6 additions & 6 deletions lib/internal/dns/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function onlookupall(err, addresses) {

const family = this.family;

for (var i = 0; i < addresses.length; i++) {
for (let i = 0; i < addresses.length; i++) {
const address = addresses[i];

addresses[i] = {
Expand Down Expand Up @@ -121,10 +121,10 @@ function createLookupPromise(family, hostname, all, hints, verbatim) {
}

function lookup(hostname, options) {
var hints = 0;
var family = -1;
var all = false;
var verbatim = getDefaultVerbatim();
let hints = 0;
let family = -1;
let all = false;
let verbatim = getDefaultVerbatim();

// Parse arguments
if (hostname) {
Expand Down Expand Up @@ -297,7 +297,7 @@ Resolver.prototype.resolveNaptr = resolveMap.NAPTR = resolver('queryNaptr');
Resolver.prototype.resolveSoa = resolveMap.SOA = resolver('querySoa');
Resolver.prototype.reverse = resolver('getHostByAddr');
Resolver.prototype.resolve = function resolve(hostname, rrtype) {
var resolver;
let resolver;

if (rrtype !== undefined) {
validateString(rrtype, 'rrtype');
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/http2/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ const assertWithinRange = hideStackFrames(

function toHeaderObject(headers, sensitiveHeaders) {
const obj = ObjectCreate(null);
for (var n = 0; n < headers.length; n += 2) {
for (let n = 0; n < headers.length; n += 2) {
const name = headers[n];
let value = headers[n + 1];
if (name === HTTP2_HEADER_STATUS)
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/js_stream_socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class JSStreamSocket extends Socket {

this.stream.cork();
// Use `var` over `let` for performance optimization.
for (var i = 0; i < bufs.length; ++i)
for (let i = 0; i < bufs.length; ++i)
this.stream.write(bufs[i], done);
this.stream.uncork();

Expand Down

0 comments on commit ff14db9

Please sign in to comment.