summaryrefslogtreecommitdiff
path: root/lib/net.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-03-26 05:21:27 +0100
committerMichaël Zasso <targos@protonmail.com>2019-03-30 13:16:39 +0100
commitf86f5736da72ad4f3fb50692461222590e2f0258 (patch)
tree6fee263bfca24abbf76b7a3f1517b8184c29f077 /lib/net.js
parentf0b3855a90bc5f68fe38ea5e7c69d30ae7d81a27 (diff)
downloadandroid-node-v8-f86f5736da72ad4f3fb50692461222590e2f0258.tar.gz
android-node-v8-f86f5736da72ad4f3fb50692461222590e2f0258.tar.bz2
android-node-v8-f86f5736da72ad4f3fb50692461222590e2f0258.zip
benchmark,lib: change var to const
Refs: https://github.com/nodejs/node/pull/26679 PR-URL: https://github.com/nodejs/node/pull/26915 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'lib/net.js')
-rw-r--r--lib/net.js49
1 files changed, 25 insertions, 24 deletions
diff --git a/lib/net.js b/lib/net.js
index b6fa334984..99d3fc2ed7 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -153,10 +153,10 @@ function createServer(options, connectionListener) {
// connect(path, [cb]);
//
function connect(...args) {
- var normalized = normalizeArgs(args);
- var options = normalized[0];
+ const normalized = normalizeArgs(args);
+ const options = normalized[0];
debug('createConnection', normalized);
- var socket = new Socket(options);
+ const socket = new Socket(options);
if (options.timeout) {
socket.setTimeout(options.timeout);
@@ -201,7 +201,7 @@ function normalizeArgs(args) {
}
}
- var cb = args[args.length - 1];
+ const cb = args[args.length - 1];
if (typeof cb !== 'function')
arr = [options, null];
else
@@ -360,11 +360,11 @@ Socket.prototype._final = function(cb) {
debug('_final: not ended, call shutdown()');
- var req = new ShutdownWrap();
+ const req = new ShutdownWrap();
req.oncomplete = afterShutdown;
req.handle = this._handle;
req.callback = cb;
- var err = this._handle.shutdown(req);
+ const err = this._handle.shutdown(req);
if (err === 1) // synchronous finish
return afterShutdown.call(req, 0);
@@ -374,7 +374,7 @@ Socket.prototype._final = function(cb) {
function afterShutdown(status) {
- var self = this.handle[owner_symbol];
+ const self = this.handle[owner_symbol];
debug('afterShutdown destroyed=%j', self.destroyed,
self._readableState);
@@ -401,7 +401,7 @@ function writeAfterFIN(chunk, encoding, cb) {
}
// eslint-disable-next-line no-restricted-syntax
- var er = new Error('This socket has been ended by the other party');
+ const er = new Error('This socket has been ended by the other party');
er.code = 'EPIPE';
process.nextTick(emitErrorNT, this, er);
if (typeof cb === 'function') {
@@ -854,8 +854,8 @@ Socket.prototype.connect = function(...args) {
} else {
normalized = normalizeArgs(args);
}
- var options = normalized[0];
- var cb = normalized[1];
+ const options = normalized[0];
+ const cb = normalized[1];
if (this.write !== Socket.prototype.write)
this.write = Socket.prototype.write;
@@ -868,7 +868,7 @@ Socket.prototype.connect = function(...args) {
}
const { path } = options;
- var pipe = !!path;
+ const pipe = !!path;
debug('pipe', pipe, path);
if (!this._handle) {
@@ -900,8 +900,9 @@ Socket.prototype.connect = function(...args) {
function lookupAndConnect(self, options) {
- var { port, localAddress, localPort } = options;
- var host = options.host || 'localhost';
+ const { localAddress, localPort } = options;
+ const host = options.host || 'localhost';
+ let { port } = options;
if (localAddress && !isIP(localAddress)) {
throw new ERR_INVALID_IP_ADDRESS(localAddress);
@@ -923,7 +924,7 @@ function lookupAndConnect(self, options) {
port |= 0;
// If host is an IP, skip performing a lookup
- var addressType = isIP(host);
+ const addressType = isIP(host);
if (addressType) {
defaultTriggerAsyncIdScope(self[async_id_symbol], process.nextTick, () => {
if (self.connecting)
@@ -942,7 +943,7 @@ function lookupAndConnect(self, options) {
if (dns === undefined) dns = require('dns');
- var dnsopts = {
+ const dnsopts = {
family: options.family,
hints: options.hints || 0
};
@@ -957,7 +958,7 @@ function lookupAndConnect(self, options) {
debug('connect: find host', host);
debug('connect: dns options', dnsopts);
self._host = host;
- var lookup = options.lookup || dns.lookup;
+ const lookup = options.lookup || dns.lookup;
defaultTriggerAsyncIdScope(self[async_id_symbol], function() {
lookup(host, dnsopts, function emitLookup(err, ip, addressType) {
self.emit('lookup', err, ip, addressType, host);
@@ -1024,7 +1025,7 @@ Socket.prototype.unref = function() {
function afterConnect(status, handle, req, readable, writable) {
- var self = handle[owner_symbol];
+ const self = handle[owner_symbol];
// Callback may come after call to destroy
if (self.destroyed) {
@@ -1226,7 +1227,7 @@ function setupListenHandle(address, port, addressType, backlog, fd, flags) {
// Use a backlog of 512 entries. We pass 511 to the listen() call because
// the kernel does: backlogsize = roundup_pow_of_two(backlogsize + 1);
// which will thus give us a backlog of 512 entries.
- var err = this._handle.listen(backlog || 511);
+ const err = this._handle.listen(backlog || 511);
if (err) {
var ex = uvExceptionWithHostPort(err, 'listen', address, port);
@@ -1310,9 +1311,9 @@ function listenInCluster(server, address, port, addressType,
Server.prototype.listen = function(...args) {
- var normalized = normalizeArgs(args);
+ const normalized = normalizeArgs(args);
var options = normalized[0];
- var cb = normalized[1];
+ const cb = normalized[1];
if (this._handle) {
throw new ERR_SERVER_ALREADY_LISTEN();
@@ -1321,7 +1322,7 @@ Server.prototype.listen = function(...args) {
if (cb !== null) {
this.once('listening', cb);
}
- var backlogFromArgs =
+ const backlogFromArgs =
// (handle, backlog) or (path, backlog) or (port, backlog)
toNumber(args.length > 1 && args[1]) ||
toNumber(args.length > 2 && args[2]); // (port, host, backlog)
@@ -1446,8 +1447,8 @@ Server.prototype.address = function() {
};
function onconnection(err, clientHandle) {
- var handle = this;
- var self = handle[owner_symbol];
+ const handle = this;
+ const self = handle[owner_symbol];
debug('onconnection');
@@ -1461,7 +1462,7 @@ function onconnection(err, clientHandle) {
return;
}
- var socket = new Socket({
+ const socket = new Socket({
handle: clientHandle,
allowHalfOpen: self.allowHalfOpen,
pauseOnCreate: self.pauseOnConnect,