Skip to content

Commit 6e887cc

Browse files
thefourtheyervagg
authored andcommitted
lib,test: update let to const where applicable
As per the `prefer-const` eslint rule, few instances of `let` have been identified to be better with `const`. This patch updates all those instances. Refer: #3118 PR-URL: #3152 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 701e38c commit 6e887cc

10 files changed

+21
-20
lines changed

lib/cluster.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ function masterInit() {
291291
var match = execArgv[i].match(/^(--debug|--debug-(brk|port))(=\d+)?$/);
292292

293293
if (match) {
294-
let debugPort = process.debugPort + debugPortOffset;
294+
const debugPort = process.debugPort + debugPortOffset;
295295
++debugPortOffset;
296296
execArgv[i] = match[1] + '=' + debugPort;
297297
}

lib/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ function formatCollectionIterator(ctx, value, recurseTimes, visibleKeys, keys) {
517517
var nextRecurseTimes = recurseTimes === null ? null : recurseTimes - 1;
518518
var vals = mirror.preview();
519519
var output = [];
520-
for (let o of vals) {
520+
for (const o of vals) {
521521
output.push(formatValue(ctx, o, nextRecurseTimes));
522522
}
523523
return output;

test/parallel/test-async-wrap-check-providers.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,17 @@ process.on('SIGINT', () => process.exit());
7373

7474
// Run from closed net server above.
7575
function checkTLS() {
76-
let options = {
76+
const options = {
7777
key: fs.readFileSync(common.fixturesDir + '/keys/ec-key.pem'),
7878
cert: fs.readFileSync(common.fixturesDir + '/keys/ec-cert.pem')
7979
};
80-
let server = tls.createServer(options, noop).listen(common.PORT, function() {
81-
tls.connect(common.PORT, { rejectUnauthorized: false }, function() {
82-
this.destroy();
83-
server.close();
80+
const server = tls.createServer(options, noop)
81+
.listen(common.PORT, function() {
82+
tls.connect(common.PORT, { rejectUnauthorized: false }, function() {
83+
this.destroy();
84+
server.close();
85+
});
8486
});
85-
});
8687
}
8788

8889
zlib.createGzip();

test/parallel/test-buffer-zero-fill-reset.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ function testUint8Array(ui) {
1414

1515
for (let i = 0; i < 100; i++) {
1616
new Buffer(0);
17-
let ui = new Uint8Array(65);
17+
const ui = new Uint8Array(65);
1818
assert.ok(testUint8Array(ui), 'Uint8Array is not zero-filled');
1919
}

test/parallel/test-http-flush-headers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ server.on('request', function(req, res) {
1010
server.close();
1111
});
1212
server.listen(common.PORT, '127.0.0.1', function() {
13-
let req = http.request({
13+
const req = http.request({
1414
method: 'GET',
1515
host: '127.0.0.1',
1616
port: common.PORT,

test/parallel/test-http-response-multiheaders.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ const norepeat = [
1717
const server = http.createServer(function(req, res) {
1818
var num = req.headers['x-num'];
1919
if (num == 1) {
20-
for (let name of norepeat) {
20+
for (const name of norepeat) {
2121
res.setHeader(name, ['A', 'B']);
2222
}
2323
res.setHeader('X-A', ['A', 'B']);
2424
} else if (num == 2) {
25-
let headers = {};
26-
for (let name of norepeat) {
25+
const headers = {};
26+
for (const name of norepeat) {
2727
headers[name] = ['A', 'B'];
2828
}
2929
headers['X-A'] = ['A', 'B'];
@@ -44,7 +44,7 @@ server.listen(common.PORT, common.mustCall(function() {
4444
{port:common.PORT, headers:{'x-num': n}},
4545
common.mustCall(function(res) {
4646
if (n == 2) server.close();
47-
for (let name of norepeat) {
47+
for (const name of norepeat) {
4848
assert.equal(res.headers[name], 'A');
4949
}
5050
assert.equal(res.headers['x-a'], 'A, B');

test/parallel/test-tls-socket-default-options.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function testSocketOptions(socket, socketOptions) {
3333
setImmediate(runTests);
3434
});
3535
}).listen(common.PORT, function() {
36-
let c = new tls.TLSSocket(socket, socketOptions);
36+
const c = new tls.TLSSocket(socket, socketOptions);
3737
c.connect(common.PORT, function() {
3838
c.end(sent);
3939
});

test/parallel/test-util-inspect.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ map.set(1, 2);
135135
var mirror = Debug.MakeMirror(map.entries(), true);
136136
var vals = mirror.preview();
137137
var valsOutput = [];
138-
for (let o of vals) {
138+
for (const o of vals) {
139139
valsOutput.push(o);
140140
}
141141

test/parallel/test-zlib-truncated.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ const inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing el'
2222
].forEach(function(methods) {
2323
zlib[methods.comp](inputString, function(err, compressed) {
2424
assert(!err);
25-
let truncated = compressed.slice(0, compressed.length / 2);
25+
const truncated = compressed.slice(0, compressed.length / 2);
2626

2727
// sync sanity
2828
assert.doesNotThrow(function() {
29-
let decompressed = zlib[methods.decompSync](compressed);
29+
const decompressed = zlib[methods.decompSync](compressed);
3030
assert.equal(decompressed, inputString);
3131
});
3232

test/sequential/test-child-process-fork-getconnections.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const net = require('net');
66
const count = 12;
77

88
if (process.argv[2] === 'child') {
9-
let sockets = [];
9+
const sockets = [];
1010

1111
process.on('message', function(m, socket) {
1212
function sendClosed(id) {
@@ -42,7 +42,7 @@ if (process.argv[2] === 'child') {
4242
});
4343

4444
const server = net.createServer();
45-
let sockets = [];
45+
const sockets = [];
4646
let sent = 0;
4747

4848
server.on('connection', function(socket) {

0 commit comments

Comments
 (0)