dgram: scope redeclared variables
authorRich Trott <rtrott@gmail.com>
Fri, 29 Jan 2016 04:08:57 +0000 (20:08 -0800)
committerMyles Borins <mborins@us.ibm.com>
Wed, 2 Mar 2016 22:01:11 +0000 (14:01 -0800)
A few variables in `lib/dgram.js` are redeclared with `var` in a scope
where they have already been declared. These instances can be scoped
more narrowly with `const`, so that's what this change does.

PR-URL: https://github.com/nodejs/node/pull/4940
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
lib/dgram.js

index da1308d7074222419ad06f32c737c36ae2e447b3..91d64dcee12c0f49d054bc62fab0fe9840888e60 100644 (file)
@@ -40,13 +40,13 @@ function lookup6(address, callback) {
 
 function newHandle(type) {
   if (type == 'udp4') {
-    var handle = new UDP();
+    const handle = new UDP();
     handle.lookup = lookup4;
     return handle;
   }
 
   if (type == 'udp6') {
-    var handle = new UDP();
+    const handle = new UDP();
     handle.lookup = lookup6;
     handle.bind = handle.bind6;
     handle.send = handle.send6;
@@ -209,7 +209,7 @@ Socket.prototype.bind = function(port_ /*, address, callback*/) {
       if (!self._handle)
         return; // handle has been closed in the mean time
 
-      var err = self._handle.bind(ip, port || 0, flags);
+      const err = self._handle.bind(ip, port || 0, flags);
       if (err) {
         var ex = exceptionWithHostPort(err, 'bind', ip, port);
         self.emit('error', ex);