| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ff4f236 commit 21be4b1
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -155,7 +155,7 @@ function createServer(options, connectionListener) { | |||
| 155 | 155 | ||
| 156 | 156 | // Target API: | |
| 157 | 157 | // | |
| 158 | - // var s = net.connect({port: 80, host: 'google.com'}, function() { | ||
| 158 | + // let s = net.connect({port: 80, host: 'google.com'}, function() { | ||
| 159 | 159 | // ... | |
| 160 | 160 | // }); | |
| 161 | 161 | // | |
@@ -190,7 +190,7 @@ function connect(...args) { | |||
| 190 | 190 | // For Server.prototype.listen(), the [...] part is [, backlog] | |
| 191 | 191 | // but will not be handled here (handled in listen()) | |
| 192 | 192 | function normalizeArgs(args) { | |
| 193 | - var arr; | ||
| 193 | + let arr; | ||
| 194 | 194 | ||
| 195 | 195 | if (args.length === 0) { | |
| 196 | 196 | arr = [{}, null]; | |
@@ -199,7 +199,7 @@ function normalizeArgs(args) { | |||
| 199 | 199 | } | |
| 200 | 200 | ||
| 201 | 201 | const arg0 = args[0]; | |
| 202 | - var options = {}; | ||
| 202 | + let options = {}; | ||
| 203 | 203 | if (typeof arg0 === 'object' && arg0 !== null) { | |
| 204 | 204 | // (options[...][, cb]) | |
| 205 | 205 | options = arg0; | |
@@ -382,7 +382,7 @@ ObjectSetPrototypeOf(Socket, stream.Duplex); | |||
| 382 | 382 | ||
| 383 | 383 | // Refresh existing timeouts. | |
| 384 | 384 | Socket.prototype._unrefTimer = function _unrefTimer() { | |
| 385 | - for (var s = this; s !== null; s = s._parent) { | ||
| 385 | + for (let s = this; s !== null; s = s._parent) { | ||
| 386 | 386 | if (s[kTimeout]) | |
| 387 | 387 | s[kTimeout].refresh(); | |
| 388 | 388 | } | |
@@ -558,7 +558,7 @@ function tryReadStart(socket) { | |||
| 558 | 558 | // Not already reading, start the flow | |
| 559 | 559 | debug('Socket._handle.readStart'); | |
| 560 | 560 | socket._handle.reading = true; | |
| 561 | - var err = socket._handle.readStart(); | ||
| 561 | + const err = socket._handle.readStart(); | ||
| 562 | 562 | if (err) | |
| 563 | 563 | socket.destroy(errnoException(err, 'read')); | |
| 564 | 564 | } | |
@@ -646,15 +646,15 @@ Socket.prototype._destroy = function(exception, cb) { | |||
| 646 | 646 | ||
| 647 | 647 | this.readable = this.writable = false; | |
| 648 | 648 | ||
| 649 | - for (var s = this; s !== null; s = s._parent) { | ||
| 649 | + for (let s = this; s !== null; s = s._parent) { | ||
| 650 | 650 | clearTimeout(s[kTimeout]); | |
| 651 | 651 | } | |
| 652 | 652 | ||
| 653 | 653 | debug('close'); | |
| 654 | 654 | if (this._handle) { | |
| 655 | 655 | if (this !== process.stderr) | |
| 656 | 656 | debug('close handle'); | |
| 657 | - var isException = exception ? true : false; | ||
| 657 | + const isException = exception ? true : false; | ||
| 658 | 658 | // `bytesRead` and `kBytesWritten` should be accessible after `.destroy()` | |
| 659 | 659 | this[kBytesRead] = this._handle.bytesRead; | |
| 660 | 660 | this[kBytesWritten] = this._handle.bytesWritten; | |
@@ -686,8 +686,8 @@ Socket.prototype._getpeername = function() { | |||
| 686 | 686 | if (!this._handle || !this._handle.getpeername) { | |
| 687 | 687 | return {}; | |
| 688 | 688 | } | |
| 689 | - var out = {}; | ||
| 690 | - var err = this._handle.getpeername(out); | ||
| 689 | + const out = {}; | ||
| 690 | + const err = this._handle.getpeername(out); | ||
| 691 | 691 | if (err) return {}; // FIXME(bnoordhuis) Throw? | |
| 692 | 692 | this._peername = out; | |
| 693 | 693 | } | |
@@ -724,8 +724,8 @@ Socket.prototype._getsockname = function() { | |||
| 724 | 724 | return {}; | |
| 725 | 725 | } | |
| 726 | 726 | if (!this._sockname) { | |
| 727 | - var out = {}; | ||
| 728 | - var err = this._handle.getsockname(out); | ||
| 727 | + const out = {}; | ||
| 728 | + const err = this._handle.getsockname(out); | ||
| 729 | 729 | if (err) return {}; // FIXME(bnoordhuis) Throw? | |
| 730 | 730 | this._sockname = out; | |
| 731 | 731 | } | |
@@ -796,7 +796,7 @@ protoGetter('_bytesDispatched', function _bytesDispatched() { | |||
| 796 | 796 | }); | |
| 797 | 797 | ||
| 798 | 798 | protoGetter('bytesWritten', function bytesWritten() { | |
| 799 | - var bytes = this._bytesDispatched; | ||
| 799 | + let bytes = this._bytesDispatched; | ||
| 800 | 800 | const state = this._writableState; | |
| 801 | 801 | const data = this._pendingData; | |
| 802 | 802 | const encoding = this._pendingEncoding; | |
@@ -813,7 +813,7 @@ protoGetter('bytesWritten', function bytesWritten() { | |||
| 813 | 813 | ||
| 814 | 814 | if (Array.isArray(data)) { | |
| 815 | 815 | // Was a writev, iterate over chunks to get total length | |
| 816 | - for (var i = 0; i < data.length; i++) { | ||
| 816 | + for (let i = 0; i < data.length; i++) { | ||
| 817 | 817 | const chunk = data[i]; | |
| 818 | 818 | ||
| 819 | 819 | if (data.allBuffers || chunk instanceof Buffer) | |
@@ -843,7 +843,7 @@ function checkBindError(err, port, handle) { | |||
| 843 | 843 | // getsockname() method. Non-issue for now, the cluster module doesn't | |
| 844 | 844 | // really support pipes anyway. | |
| 845 | 845 | if (err === 0 && port > 0 && handle.getsockname) { | |
| 846 | - var out = {}; | ||
| 846 | + const out = {}; | ||
| 847 | 847 | err = handle.getsockname(out); | |
| 848 | 848 | if (err === 0 && port !== out.port) { | |
| 849 | 849 | debug(`checkBindError, bound to ${out.port} instead of ${port}`); | |
@@ -861,7 +861,7 @@ function internalConnect( | |||
| 861 | 861 | ||
| 862 | 862 | assert(self.connecting); | |
| 863 | 863 | ||
| 864 | - var err; | ||
| 864 | + let err; | ||
| 865 | 865 | ||
| 866 | 866 | if (localAddress || localPort) { | |
| 867 | 867 | if (addressType === 4) { | |
@@ -903,8 +903,8 @@ function internalConnect( | |||
| 903 | 903 | } | |
| 904 | 904 | ||
| 905 | 905 | if (err) { | |
| 906 | - var sockname = self._getsockname(); | ||
| 907 | - var details; | ||
| 906 | + const sockname = self._getsockname(); | ||
| 907 | + let details; | ||
| 908 | 908 | ||
| 909 | 909 | if (sockname) { | |
| 910 | 910 | details = sockname.address + ':' + sockname.port; | |
@@ -1127,15 +1127,15 @@ function afterConnect(status, handle, req, readable, writable) { | |||
| 1127 | 1127 | ||
| 1128 | 1128 | } else { | |
| 1129 | 1129 | self.connecting = false; | |
| 1130 | - var details; | ||
| 1130 | + let details; | ||
| 1131 | 1131 | if (req.localAddress && req.localPort) { | |
| 1132 | 1132 | details = req.localAddress + ':' + req.localPort; | |
| 1133 | 1133 | } | |
| 1134 | - var ex = exceptionWithHostPort(status, | ||
| 1135 | - 'connect', | ||
| 1136 | - req.address, | ||
| 1137 | - req.port, | ||
| 1138 | - details); | ||
| 1134 | + const ex = exceptionWithHostPort(status, | ||
| 1135 | + 'connect', | ||
| 1136 | + req.address, | ||
| 1137 | + req.port, | ||
| 1138 | + details); | ||
| 1139 | 1139 | if (details) { | |
| 1140 | 1140 | ex.localAddress = req.localAddress; | |
| 1141 | 1141 | ex.localPort = req.localPort; | |
@@ -1199,11 +1199,11 @@ function toNumber(x) { return (x = Number(x)) >= 0 ? x : false; } | |||
| 1199 | 1199 | ||
| 1200 | 1200 | // Returns handle if it can be created, or error code if it can't | |
| 1201 | 1201 | function createServerHandle(address, port, addressType, fd, flags) { | |
| 1202 | - var err = 0; | ||
| 1202 | + let err = 0; | ||
| 1203 | 1203 | // Assign handle in listen, and clean up if bind or listen fails | |
| 1204 | - var handle; | ||
| 1204 | + let handle; | ||
| 1205 | 1205 | ||
| 1206 | - var isTCP = false; | ||
| 1206 | + let isTCP = false; | ||
| 1207 | 1207 | if (typeof fd === 'number' && fd >= 0) { | |
| 1208 | 1208 | try { | |
| 1209 | 1209 | handle = createHandle(fd, true); | |
@@ -1221,7 +1221,7 @@ function createServerHandle(address, port, addressType, fd, flags) { | |||
| 1221 | 1221 | } else if (port === -1 && addressType === -1) { | |
| 1222 | 1222 | handle = new Pipe(PipeConstants.SERVER); | |
| 1223 | 1223 | if (process.platform === 'win32') { | |
| 1224 | - var instances = parseInt(process.env.NODE_PENDING_PIPE_INSTANCES); | ||
| 1224 | + const instances = parseInt(process.env.NODE_PENDING_PIPE_INSTANCES); | ||
| 1225 | 1225 | if (!Number.isNaN(instances)) { | |
| 1226 | 1226 | handle.setPendingInstances(instances); | |
| 1227 | 1227 | } | |
@@ -1266,7 +1266,7 @@ function setupListenHandle(address, port, addressType, backlog, fd, flags) { | |||
| 1266 | 1266 | } else { | |
| 1267 | 1267 | debug('setupListenHandle: create a handle'); | |
| 1268 | 1268 | ||
| 1269 | - var rval = null; | ||
| 1269 | + let rval = null; | ||
| 1270 | 1270 | ||
| 1271 | 1271 | // Try to bind to the unspecified IPv6 address, see if IPv6 is available | |
| 1272 | 1272 | if (!address && typeof fd !== 'number') { | |
@@ -1286,7 +1286,7 @@ function setupListenHandle(address, port, addressType, backlog, fd, flags) { | |||
| 1286 | 1286 | rval = createServerHandle(address, port, addressType, fd, flags); | |
| 1287 | 1287 | ||
| 1288 | 1288 | if (typeof rval === 'number') { | |
| 1289 | - var error = uvExceptionWithHostPort(rval, 'listen', address, port); | ||
| 1289 | + const error = uvExceptionWithHostPort(rval, 'listen', address, port); | ||
| 1290 | 1290 | process.nextTick(emitErrorNT, this, error); | |
| 1291 | 1291 | return; | |
| 1292 | 1292 | } | |
@@ -1303,7 +1303,7 @@ function setupListenHandle(address, port, addressType, backlog, fd, flags) { | |||
| 1303 | 1303 | const err = this._handle.listen(backlog || 511); | |
| 1304 | 1304 | ||
| 1305 | 1305 | if (err) { | |
| 1306 | - var ex = uvExceptionWithHostPort(err, 'listen', address, port); | ||
| 1306 | + const ex = uvExceptionWithHostPort(err, 'listen', address, port); | ||
| 1307 | 1307 | this._handle.close(); | |
| 1308 | 1308 | this._handle = null; | |
| 1309 | 1309 | defaultTriggerAsyncIdScope(this[async_id_symbol], | |
@@ -1370,7 +1370,7 @@ function listenInCluster(server, address, port, addressType, | |||
| 1370 | 1370 | err = checkBindError(err, port, handle); | |
| 1371 | 1371 | ||
| 1372 | 1372 | if (err) { | |
| 1373 | - var ex = exceptionWithHostPort(err, 'bind', address, port); | ||
| 1373 | + const ex = exceptionWithHostPort(err, 'bind', address, port); | ||
| 1374 | 1374 | return server.emit('error', ex); | |
| 1375 | 1375 | } | |
| 1376 | 1376 | ||
@@ -1385,7 +1385,7 @@ function listenInCluster(server, address, port, addressType, | |||
| 1385 | 1385 | ||
| 1386 | 1386 | Server.prototype.listen = function(...args) { | |
| 1387 | 1387 | const normalized = normalizeArgs(args); | |
| 1388 | - var options = normalized[0]; | ||
| 1388 | + let options = normalized[0]; | ||
| 1389 | 1389 | const cb = normalized[1]; | |
| 1390 | 1390 | ||
| 1391 | 1391 | if (this._handle) { | |
@@ -1427,7 +1427,7 @@ Server.prototype.listen = function(...args) { | |||
| 1427 | 1427 | // ([port][, host][, backlog][, cb]) where port is specified | |
| 1428 | 1428 | // or (options[, cb]) where options.port is specified | |
| 1429 | 1429 | // or if options.port is normalized as 0 before | |
| 1430 | - var backlog; | ||
| 1430 | + let backlog; | ||
| 1431 | 1431 | if (typeof options.port === 'number' || typeof options.port === 'string') { | |
| 1432 | 1432 | if (!isLegalPort(options.port)) { | |
| 1433 | 1433 | throw new ERR_SOCKET_BAD_PORT(options.port); | |
@@ -1448,7 +1448,7 @@ Server.prototype.listen = function(...args) { | |||
| 1448 | 1448 | // (path[, backlog][, cb]) or (options[, cb]) | |
| 1449 | 1449 | // where path or options.path is a UNIX domain socket or Windows pipe | |
| 1450 | 1450 | if (options.path && isPipeName(options.path)) { | |
| 1451 | - var pipeName = this._pipeName = options.path; | ||
| 1451 | + const pipeName = this._pipeName = options.path; | ||
| 1452 | 1452 | backlog = options.backlog || backlogFromArgs; | |
| 1453 | 1453 | listenInCluster(this, pipeName, -1, -1, | |
| 1454 | 1454 | backlog, undefined, options.exclusive); | |
@@ -1506,8 +1506,8 @@ ObjectDefineProperty(Server.prototype, 'listening', { | |||
| 1506 | 1506 | ||
| 1507 | 1507 | Server.prototype.address = function() { | |
| 1508 | 1508 | if (this._handle && this._handle.getsockname) { | |
| 1509 | - var out = {}; | ||
| 1510 | - var err = this._handle.getsockname(out); | ||
| 1509 | + const out = {}; | ||
| 1510 | + const err = this._handle.getsockname(out); | ||
| 1511 | 1511 | if (err) { | |
| 1512 | 1512 | throw errnoException(err, 'address'); | |
| 1513 | 1513 | } | |
@@ -1569,8 +1569,8 @@ Server.prototype.getConnections = function(cb) { | |||
| 1569 | 1569 | } | |
| 1570 | 1570 | ||
| 1571 | 1571 | // Poll workers | |
| 1572 | - var left = this._workers.length; | ||
| 1573 | - var total = this._connections; | ||
| 1572 | + let left = this._workers.length; | ||
| 1573 | + let total = this._connections; | ||
| 1574 | 1574 | ||
| 1575 | 1575 | function oncount(err, count) { | |
| 1576 | 1576 | if (err) { | |
@@ -1582,7 +1582,7 @@ Server.prototype.getConnections = function(cb) { | |||
| 1582 | 1582 | if (--left === 0) return end(null, total); | |
| 1583 | 1583 | } | |
| 1584 | 1584 | ||
| 1585 | - for (var n = 0; n < this._workers.length; n++) { | ||
| 1585 | + for (let n = 0; n < this._workers.length; n++) { | ||
| 1586 | 1586 | this._workers[n].getConnections(oncount); | |
| 1587 | 1587 | } | |
| 1588 | 1588 | ||
@@ -1607,7 +1607,7 @@ Server.prototype.close = function(cb) { | |||
| 1607 | 1607 | } | |
| 1608 | 1608 | ||
| 1609 | 1609 | if (this._usingWorkers) { | |
| 1610 | - var left = this._workers.length; | ||
| 1610 | + let left = this._workers.length; | ||
| 1611 | 1611 | const onWorkerClose = () => { | |
| 1612 | 1612 | if (--left !== 0) return; | |
| 1613 | 1613 | ||
@@ -1620,7 +1620,7 @@ Server.prototype.close = function(cb) { | |||
| 1620 | 1620 | this._connections++; | |
| 1621 | 1621 | ||
| 1622 | 1622 | // Poll workers | |
| 1623 | - for (var n = 0; n < this._workers.length; n++) | ||
| 1623 | + for (let n = 0; n < this._workers.length; n++) | ||
| 1624 | 1624 | this._workers[n].close(onWorkerClose); | |
| 1625 | 1625 | } else { | |
| 1626 | 1626 | this._emitCloseIfDrained(); | |
@@ -1690,11 +1690,11 @@ Server.prototype.unref = function() { | |||
| 1690 | 1690 | return this; | |
| 1691 | 1691 | }; | |
| 1692 | 1692 | ||
| 1693 | - var _setSimultaneousAccepts; | ||
| 1694 | - var warnSimultaneousAccepts = true; | ||
| 1693 | + let _setSimultaneousAccepts; | ||
| 1694 | + let warnSimultaneousAccepts = true; | ||
| 1695 | 1695 | ||
| 1696 | 1696 | if (process.platform === 'win32') { | |
| 1697 | - var simultaneousAccepts; | ||
| 1697 | + let simultaneousAccepts; | ||
| 1698 | 1698 | ||
| 1699 | 1699 | _setSimultaneousAccepts = function(handle) { | |
| 1700 | 1700 | if (warnSimultaneousAccepts) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments