Skip to content

Commit

Permalink
lib: replace var with let/const
Browse files Browse the repository at this point in the history
PR-URL: #30391
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
  • Loading branch information
jens-cappelle authored and targos committed Dec 1, 2019
1 parent a4c404c commit 6ff34a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions lib/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const {
}
} = primordials;

var spliceOne;
let spliceOne;

const {
kEnhanceStackBeforeInspector,
Expand Down Expand Up @@ -70,7 +70,7 @@ EventEmitter.prototype._maxListeners = undefined;

// By default EventEmitters will print a warning if more than 10 listeners are
// added to it. This is a useful default which helps finding memory leaks.
var defaultMaxListeners = 10;
let defaultMaxListeners = 10;

function checkListener(listener) {
if (typeof listener !== 'function') {
Expand Down Expand Up @@ -127,7 +127,7 @@ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
// Returns the length and line number of the first sequence of `a` that fully
// appears in `b` with a length of at least 4.
function identicalSequenceRange(a, b) {
for (var i = 0; i < a.length - 3; i++) {
for (let i = 0; i < a.length - 3; i++) {
// Find the first entry of b that matches the current entry of a.
const pos = b.indexOf(a[i]);
if (pos !== -1) {
Expand Down Expand Up @@ -224,17 +224,17 @@ EventEmitter.prototype.emit = function emit(type, ...args) {
} else {
const len = handler.length;
const listeners = arrayClone(handler, len);
for (var i = 0; i < len; ++i)
for (let i = 0; i < len; ++i)
ReflectApply(listeners[i], this, args);
}

return true;
};

function _addListener(target, type, listener, prepend) {
var m;
var events;
var existing;
let m;
let events;
let existing;

checkListener(listener);

Expand Down Expand Up @@ -363,7 +363,7 @@ EventEmitter.prototype.removeListener =
} else if (typeof list !== 'function') {
let position = -1;

for (var i = list.length - 1; i >= 0; i--) {
for (let i = list.length - 1; i >= 0; i--) {
if (list[i] === listener || list[i].listener === listener) {
originalListener = list[i].listener;
position = i;
Expand Down Expand Up @@ -432,7 +432,7 @@ EventEmitter.prototype.removeAllListeners =
this.removeListener(type, listeners);
} else if (listeners !== undefined) {
// LIFO order
for (var i = listeners.length - 1; i >= 0; i--) {
for (let i = listeners.length - 1; i >= 0; i--) {
this.removeListener(type, listeners[i]);
}
}
Expand Down Expand Up @@ -496,14 +496,14 @@ EventEmitter.prototype.eventNames = function eventNames() {

function arrayClone(arr, n) {
const copy = new Array(n);
for (var i = 0; i < n; ++i)
for (let i = 0; i < n; ++i)
copy[i] = arr[i];
return copy;
}

function unwrapListeners(arr) {
const ret = new Array(arr.length);
for (var i = 0; i < ret.length; ++i) {
for (let i = 0; i < ret.length; ++i) {
ret[i] = arr[i].listener || arr[i];
}
return ret;
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/process/task_queues.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ function nextTick(callback) {
if (process._exiting)
return;

var args;
let args;
switch (arguments.length) {
case 1: break;
case 2: args = [arguments[1]]; break;
case 3: args = [arguments[1], arguments[2]]; break;
case 4: args = [arguments[1], arguments[2], arguments[3]]; break;
default:
args = new Array(arguments.length - 1);
for (var i = 1; i < arguments.length; i++)
for (let i = 1; i < arguments.length; i++)
args[i - 1] = arguments[i];
}

Expand Down

0 comments on commit 6ff34a5

Please sign in to comment.