Skip to content

Commit 612ce66

Browse files
Trottrvagg
authored andcommitted
net: refactor redeclared variables
`lib/net.js` contained four variables that were redeclared with `var` in the same scope. This change refactors those redeclarations so they are scoped properly. PR-URL: #4963 Reviewed-By: Brian White <[email protected]> Reviewed-By: Roman Klauke <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 777ed82 commit 612ce66

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

lib/net.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -653,10 +653,8 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
653653
var chunks = new Array(data.length << 1);
654654
for (var i = 0; i < data.length; i++) {
655655
var entry = data[i];
656-
var chunk = entry.chunk;
657-
var enc = entry.encoding;
658-
chunks[i * 2] = chunk;
659-
chunks[i * 2 + 1] = enc;
656+
chunks[i * 2] = entry.chunk;
657+
chunks[i * 2 + 1] = entry.encoding;
660658
}
661659
err = this._handle.writev(req, chunks);
662660

@@ -808,14 +806,14 @@ function connect(self, address, port, addressType, localAddress, localPort) {
808806
err = bind(localAddress, localPort);
809807

810808
if (err) {
811-
var ex = exceptionWithHostPort(err, 'bind', localAddress, localPort);
809+
const ex = exceptionWithHostPort(err, 'bind', localAddress, localPort);
812810
self._destroy(ex);
813811
return;
814812
}
815813
}
816814

817815
if (addressType === 6 || addressType === 4) {
818-
var req = new TCPConnectWrap();
816+
const req = new TCPConnectWrap();
819817
req.oncomplete = afterConnect;
820818
req.address = address;
821819
req.port = port;
@@ -828,7 +826,7 @@ function connect(self, address, port, addressType, localAddress, localPort) {
828826
err = self._handle.connect6(req, address, port);
829827

830828
} else {
831-
var req = new PipeConnectWrap();
829+
const req = new PipeConnectWrap();
832830
req.address = address;
833831
req.oncomplete = afterConnect;
834832
err = self._handle.connect(req, address, afterConnect);
@@ -842,7 +840,7 @@ function connect(self, address, port, addressType, localAddress, localPort) {
842840
details = sockname.address + ':' + sockname.port;
843841
}
844842

845-
var ex = exceptionWithHostPort(err, 'connect', address, port, details);
843+
const ex = exceptionWithHostPort(err, 'connect', address, port, details);
846844
self._destroy(ex);
847845
}
848846
}
@@ -1343,15 +1341,15 @@ Server.prototype.listen = function() {
13431341
else
13441342
listen(self, null, h.port | 0, 4, backlog, undefined, h.exclusive);
13451343
} else if (h.path && isPipeName(h.path)) {
1346-
var pipeName = self._pipeName = h.path;
1344+
const pipeName = self._pipeName = h.path;
13471345
listen(self, pipeName, -1, -1, backlog, undefined, h.exclusive);
13481346
} else {
13491347
throw new Error('Invalid listen argument: ' + h);
13501348
}
13511349
}
13521350
} else if (isPipeName(arguments[0])) {
13531351
// UNIX socket or Windows pipe.
1354-
var pipeName = self._pipeName = arguments[0];
1352+
const pipeName = self._pipeName = arguments[0];
13551353
listen(self, pipeName, -1, -1, backlog);
13561354

13571355
} else if (arguments[1] === undefined ||

0 commit comments

Comments
 (0)