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

lib: replace var with let/const #30384

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/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
const { Math, Object, Reflect } = primordials;
const apply = Reflect.apply;

var spliceOne;
let spliceOne;

const {
kEnhanceStackBeforeInspector,
Expand Down Expand Up @@ -57,7 +57,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 @@ -114,7 +114,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 @@ -211,17 +211,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)
apply(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 @@ -350,7 +350,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 @@ -419,7 +419,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 @@ -483,14 +483,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