Skip to content

Commit

Permalink
net: refactor redeclared variables
Browse files Browse the repository at this point in the history
`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 <mscdex@mscdex.net>
Reviewed-By: Roman Klauke <romaaan.git@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott authored and jasnell committed Feb 1, 2016
1 parent aeb2eb7 commit 2605126
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,8 @@ Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
var chunks = new Array(data.length << 1);
for (var i = 0; i < data.length; i++) {
var entry = data[i];
var chunk = entry.chunk;
var enc = entry.encoding;
chunks[i * 2] = chunk;
chunks[i * 2 + 1] = enc;
chunks[i * 2] = entry.chunk;
chunks[i * 2 + 1] = entry.encoding;
}
err = this._handle.writev(req, chunks);

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

if (err) {
var ex = exceptionWithHostPort(err, 'bind', localAddress, localPort);
const ex = exceptionWithHostPort(err, 'bind', localAddress, localPort);
self._destroy(ex);
return;
}
}

if (addressType === 6 || addressType === 4) {
var req = new TCPConnectWrap();
const req = new TCPConnectWrap();
req.oncomplete = afterConnect;
req.address = address;
req.port = port;
Expand All @@ -828,7 +826,7 @@ function connect(self, address, port, addressType, localAddress, localPort) {
err = self._handle.connect6(req, address, port);

} else {
var req = new PipeConnectWrap();
const req = new PipeConnectWrap();
req.address = address;
req.oncomplete = afterConnect;
err = self._handle.connect(req, address, afterConnect);
Expand All @@ -842,7 +840,7 @@ function connect(self, address, port, addressType, localAddress, localPort) {
details = sockname.address + ':' + sockname.port;
}

var ex = exceptionWithHostPort(err, 'connect', address, port, details);
const ex = exceptionWithHostPort(err, 'connect', address, port, details);
self._destroy(ex);
}
}
Expand Down Expand Up @@ -1346,15 +1344,15 @@ Server.prototype.listen = function() {
else
listen(self, null, h.port | 0, 4, backlog, undefined, h.exclusive);
} else if (h.path && isPipeName(h.path)) {
var pipeName = self._pipeName = h.path;
const pipeName = self._pipeName = h.path;
listen(self, pipeName, -1, -1, backlog, undefined, h.exclusive);
} else {
throw new Error('Invalid listen argument: ' + h);
}
}
} else if (isPipeName(arguments[0])) {
// UNIX socket or Windows pipe.
var pipeName = self._pipeName = arguments[0];
const pipeName = self._pipeName = arguments[0];
listen(self, pipeName, -1, -1, backlog);

} else if (arguments[1] === undefined ||
Expand Down

0 comments on commit 2605126

Please sign in to comment.