lib,test: update let to const where applicable
authorSakthipriyan Vairamani <thechargingvolcano@gmail.com>
Thu, 8 Oct 2015 17:41:29 +0000 (23:11 +0530)
committerMyles Borins <mborins@us.ibm.com>
Tue, 19 Jan 2016 19:52:11 +0000 (11:52 -0800)
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: https://github.com/nodejs/node/issues/3118
PR-URL: https://github.com/nodejs/node/pull/3152
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
lib/cluster.js
lib/util.js
test/parallel/test-async-wrap-check-providers.js
test/parallel/test-buffer-zero-fill-reset.js
test/parallel/test-http-flush-headers.js
test/parallel/test-tls-socket-default-options.js
test/parallel/test-util-inspect.js
test/sequential/test-child-process-fork-getconnections.js

index c4c2c0d..f202f25 100644 (file)
@@ -291,7 +291,7 @@ function masterInit() {
       var match = execArgv[i].match(/^(--debug|--debug-(brk|port))(=\d+)?$/);
 
       if (match) {
-        let debugPort = process.debugPort + debugPortOffset;
+        const debugPort = process.debugPort + debugPortOffset;
         ++debugPortOffset;
         execArgv[i] = match[1] + '=' + debugPort;
       }
index a6231c8..ff95b48 100644 (file)
@@ -517,7 +517,7 @@ function formatCollectionIterator(ctx, value, recurseTimes, visibleKeys, keys) {
   var nextRecurseTimes = recurseTimes === null ? null : recurseTimes - 1;
   var vals = mirror.preview();
   var output = [];
-  for (let o of vals) {
+  for (const o of vals) {
     output.push(formatValue(ctx, o, nextRecurseTimes));
   }
   return output;
index 2d7d318..45dd8d4 100644 (file)
@@ -73,16 +73,17 @@ process.on('SIGINT', () => process.exit());
 
 // Run from closed net server above.
 function checkTLS() {
-  let options = {
+  const options = {
     key: fs.readFileSync(common.fixturesDir + '/keys/ec-key.pem'),
     cert: fs.readFileSync(common.fixturesDir + '/keys/ec-cert.pem')
   };
-  let server = tls.createServer(options, noop).listen(common.PORT, function() {
-    tls.connect(common.PORT, { rejectUnauthorized: false }, function() {
-      this.destroy();
-      server.close();
+  const server = tls.createServer(options, noop)
+    .listen(common.PORT, function() {
+      tls.connect(common.PORT, { rejectUnauthorized: false }, function() {
+        this.destroy();
+        server.close();
+      });
     });
-  });
 }
 
 zlib.createGzip();
index 52203a9..56fb778 100644 (file)
@@ -14,6 +14,6 @@ function testUint8Array(ui) {
 
 for (let i = 0; i < 100; i++) {
   new Buffer(0);
-  let ui = new Uint8Array(65);
+  const ui = new Uint8Array(65);
   assert.ok(testUint8Array(ui), 'Uint8Array is not zero-filled');
 }
index e3c9761..5e91a46 100644 (file)
@@ -10,7 +10,7 @@ server.on('request', function(req, res) {
   server.close();
 });
 server.listen(common.PORT, '127.0.0.1', function() {
-  let req = http.request({
+  const req = http.request({
     method: 'GET',
     host: '127.0.0.1',
     port: common.PORT,
index 3af03a0..7b41d0f 100644 (file)
@@ -33,7 +33,7 @@ function testSocketOptions(socket, socketOptions) {
       setImmediate(runTests);
     });
   }).listen(common.PORT, function() {
-    let c = new tls.TLSSocket(socket, socketOptions);
+    const c = new tls.TLSSocket(socket, socketOptions);
     c.connect(common.PORT, function() {
       c.end(sent);
     });
index 444c016..320d5e4 100644 (file)
@@ -135,7 +135,7 @@ map.set(1, 2);
 var mirror = Debug.MakeMirror(map.entries(), true);
 var vals = mirror.preview();
 var valsOutput = [];
-for (let o of vals) {
+for (const o of vals) {
   valsOutput.push(o);
 }
 
index 934df28..a7521f1 100644 (file)
@@ -6,7 +6,7 @@ const net = require('net');
 const count = 12;
 
 if (process.argv[2] === 'child') {
-  let sockets = [];
+  const sockets = [];
 
   process.on('message', function(m, socket) {
     function sendClosed(id) {
@@ -42,7 +42,7 @@ if (process.argv[2] === 'child') {
   });
 
   const server = net.createServer();
-  let sockets = [];
+  const sockets = [];
   let sent = 0;
 
   server.on('connection', function(socket) {