Skip to content

Commit 78b2d86

Browse files
nath1astargos
authored andcommitted
net: replaced vars to lets and consts
PR-URL: #30401 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 0654054 commit 78b2d86

1 file changed

Lines changed: 44 additions & 44 deletions

File tree

‎lib/net.js‎

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function createServer(options, connectionListener) {
155155

156156
// Target API:
157157
//
158-
// var s = net.connect({port: 80, host: 'google.com'}, function() {
158+
// let s = net.connect({port: 80, host: 'google.com'}, function() {
159159
// ...
160160
// });
161161
//
@@ -190,7 +190,7 @@ function connect(...args) {
190190
// For Server.prototype.listen(), the [...] part is [, backlog]
191191
// but will not be handled here (handled in listen())
192192
functionnormalizeArgs(args){
193-
vararr;
193+
letarr;
194194

195195
if(args.length===0){
196196
arr=[{},null];
@@ -199,7 +199,7 @@ function normalizeArgs(args) {
199199
}
200200

201201
constarg0=args[0];
202-
varoptions={};
202+
letoptions={};
203203
if(typeofarg0==='object'&&arg0!==null){
204204
// (options[...][, cb])
205205
options=arg0;
@@ -382,7 +382,7 @@ ObjectSetPrototypeOf(Socket, stream.Duplex);
382382

383383
// Refresh existing timeouts.
384384
Socket.prototype._unrefTimer=function_unrefTimer(){
385-
for(vars=this;s!==null;s=s._parent){
385+
for(lets=this;s!==null;s=s._parent){
386386
if(s[kTimeout])
387387
s[kTimeout].refresh();
388388
}
@@ -558,7 +558,7 @@ function tryReadStart(socket) {
558558
// Not already reading, start the flow
559559
debug('Socket._handle.readStart');
560560
socket._handle.reading=true;
561-
varerr=socket._handle.readStart();
561+
consterr=socket._handle.readStart();
562562
if(err)
563563
socket.destroy(errnoException(err,'read'));
564564
}
@@ -646,15 +646,15 @@ Socket.prototype._destroy = function(exception, cb) {
646646

647647
this.readable=this.writable=false;
648648

649-
for(vars=this;s!==null;s=s._parent){
649+
for(lets=this;s!==null;s=s._parent){
650650
clearTimeout(s[kTimeout]);
651651
}
652652

653653
debug('close');
654654
if(this._handle){
655655
if(this!==process.stderr)
656656
debug('close handle');
657-
varisException=exception ? true : false;
657+
constisException=exception ? true : false;
658658
// `bytesRead` and `kBytesWritten` should be accessible after `.destroy()`
659659
this[kBytesRead]=this._handle.bytesRead;
660660
this[kBytesWritten]=this._handle.bytesWritten;
@@ -686,8 +686,8 @@ Socket.prototype._getpeername = function() {
686686
if(!this._handle||!this._handle.getpeername){
687687
return{};
688688
}
689-
varout={};
690-
varerr=this._handle.getpeername(out);
689+
constout={};
690+
consterr=this._handle.getpeername(out);
691691
if(err)return{};// FIXME(bnoordhuis) Throw?
692692
this._peername=out;
693693
}
@@ -724,8 +724,8 @@ Socket.prototype._getsockname = function() {
724724
return{};
725725
}
726726
if(!this._sockname){
727-
varout={};
728-
varerr=this._handle.getsockname(out);
727+
constout={};
728+
consterr=this._handle.getsockname(out);
729729
if(err)return{};// FIXME(bnoordhuis) Throw?
730730
this._sockname=out;
731731
}
@@ -796,7 +796,7 @@ protoGetter('_bytesDispatched', function _bytesDispatched() {
796796
});
797797

798798
protoGetter('bytesWritten',functionbytesWritten(){
799-
varbytes=this._bytesDispatched;
799+
letbytes=this._bytesDispatched;
800800
conststate=this._writableState;
801801
constdata=this._pendingData;
802802
constencoding=this._pendingEncoding;
@@ -813,7 +813,7 @@ protoGetter('bytesWritten', function bytesWritten() {
813813

814814
if(Array.isArray(data)){
815815
// Was a writev, iterate over chunks to get total length
816-
for(vari=0;i<data.length;i++){
816+
for(leti=0;i<data.length;i++){
817817
constchunk=data[i];
818818

819819
if(data.allBuffers||chunkinstanceofBuffer)
@@ -843,7 +843,7 @@ function checkBindError(err, port, handle) {
843843
// getsockname() method. Non-issue for now, the cluster module doesn't
844844
// really support pipes anyway.
845845
if(err===0&&port>0&&handle.getsockname){
846-
varout={};
846+
constout={};
847847
err=handle.getsockname(out);
848848
if(err===0&&port!==out.port){
849849
debug(`checkBindError, bound to ${out.port} instead of ${port}`);
@@ -861,7 +861,7 @@ function internalConnect(
861861

862862
assert(self.connecting);
863863

864-
varerr;
864+
leterr;
865865

866866
if(localAddress||localPort){
867867
if(addressType===4){
@@ -903,8 +903,8 @@ function internalConnect(
903903
}
904904

905905
if(err){
906-
varsockname=self._getsockname();
907-
vardetails;
906+
constsockname=self._getsockname();
907+
letdetails;
908908

909909
if(sockname){
910910
details=sockname.address+':'+sockname.port;
@@ -1127,15 +1127,15 @@ function afterConnect(status, handle, req, readable, writable) {
11271127

11281128
}else{
11291129
self.connecting=false;
1130-
vardetails;
1130+
letdetails;
11311131
if(req.localAddress&&req.localPort){
11321132
details=req.localAddress+':'+req.localPort;
11331133
}
1134-
varex=exceptionWithHostPort(status,
1135-
'connect',
1136-
req.address,
1137-
req.port,
1138-
details);
1134+
constex=exceptionWithHostPort(status,
1135+
'connect',
1136+
req.address,
1137+
req.port,
1138+
details);
11391139
if(details){
11401140
ex.localAddress=req.localAddress;
11411141
ex.localPort=req.localPort;
@@ -1199,11 +1199,11 @@ function toNumber(x) { return (x = Number(x)) >= 0 ? x : false; }
11991199

12001200
// Returns handle if it can be created, or error code if it can't
12011201
functioncreateServerHandle(address,port,addressType,fd,flags){
1202-
varerr=0;
1202+
leterr=0;
12031203
// Assign handle in listen, and clean up if bind or listen fails
1204-
varhandle;
1204+
lethandle;
12051205

1206-
varisTCP=false;
1206+
letisTCP=false;
12071207
if(typeoffd==='number'&&fd>=0){
12081208
try{
12091209
handle=createHandle(fd,true);
@@ -1221,7 +1221,7 @@ function createServerHandle(address, port, addressType, fd, flags) {
12211221
}elseif(port===-1&&addressType===-1){
12221222
handle=newPipe(PipeConstants.SERVER);
12231223
if(process.platform==='win32'){
1224-
varinstances=parseInt(process.env.NODE_PENDING_PIPE_INSTANCES);
1224+
constinstances=parseInt(process.env.NODE_PENDING_PIPE_INSTANCES);
12251225
if(!Number.isNaN(instances)){
12261226
handle.setPendingInstances(instances);
12271227
}
@@ -1266,7 +1266,7 @@ function setupListenHandle(address, port, addressType, backlog, fd, flags) {
12661266
}else{
12671267
debug('setupListenHandle: create a handle');
12681268

1269-
varrval=null;
1269+
letrval=null;
12701270

12711271
// Try to bind to the unspecified IPv6 address, see if IPv6 is available
12721272
if(!address&&typeoffd!=='number'){
@@ -1286,7 +1286,7 @@ function setupListenHandle(address, port, addressType, backlog, fd, flags) {
12861286
rval=createServerHandle(address,port,addressType,fd,flags);
12871287

12881288
if(typeofrval==='number'){
1289-
varerror=uvExceptionWithHostPort(rval,'listen',address,port);
1289+
consterror=uvExceptionWithHostPort(rval,'listen',address,port);
12901290
process.nextTick(emitErrorNT,this,error);
12911291
return;
12921292
}
@@ -1303,7 +1303,7 @@ function setupListenHandle(address, port, addressType, backlog, fd, flags) {
13031303
consterr=this._handle.listen(backlog||511);
13041304

13051305
if(err){
1306-
varex=uvExceptionWithHostPort(err,'listen',address,port);
1306+
constex=uvExceptionWithHostPort(err,'listen',address,port);
13071307
this._handle.close();
13081308
this._handle=null;
13091309
defaultTriggerAsyncIdScope(this[async_id_symbol],
@@ -1370,7 +1370,7 @@ function listenInCluster(server, address, port, addressType,
13701370
err=checkBindError(err,port,handle);
13711371

13721372
if(err){
1373-
varex=exceptionWithHostPort(err,'bind',address,port);
1373+
constex=exceptionWithHostPort(err,'bind',address,port);
13741374
returnserver.emit('error',ex);
13751375
}
13761376

@@ -1385,7 +1385,7 @@ function listenInCluster(server, address, port, addressType,
13851385

13861386
Server.prototype.listen=function(...args){
13871387
constnormalized=normalizeArgs(args);
1388-
varoptions=normalized[0];
1388+
letoptions=normalized[0];
13891389
constcb=normalized[1];
13901390

13911391
if(this._handle){
@@ -1427,7 +1427,7 @@ Server.prototype.listen = function(...args) {
14271427
// ([port][, host][, backlog][, cb]) where port is specified
14281428
// or (options[, cb]) where options.port is specified
14291429
// or if options.port is normalized as 0 before
1430-
varbacklog;
1430+
letbacklog;
14311431
if(typeofoptions.port==='number'||typeofoptions.port==='string'){
14321432
if(!isLegalPort(options.port)){
14331433
thrownewERR_SOCKET_BAD_PORT(options.port);
@@ -1448,7 +1448,7 @@ Server.prototype.listen = function(...args) {
14481448
// (path[, backlog][, cb]) or (options[, cb])
14491449
// where path or options.path is a UNIX domain socket or Windows pipe
14501450
if(options.path&&isPipeName(options.path)){
1451-
varpipeName=this._pipeName=options.path;
1451+
constpipeName=this._pipeName=options.path;
14521452
backlog=options.backlog||backlogFromArgs;
14531453
listenInCluster(this,pipeName,-1,-1,
14541454
backlog,undefined,options.exclusive);
@@ -1506,8 +1506,8 @@ ObjectDefineProperty(Server.prototype, 'listening', {
15061506

15071507
Server.prototype.address=function(){
15081508
if(this._handle&&this._handle.getsockname){
1509-
varout={};
1510-
varerr=this._handle.getsockname(out);
1509+
constout={};
1510+
consterr=this._handle.getsockname(out);
15111511
if(err){
15121512
throwerrnoException(err,'address');
15131513
}
@@ -1569,8 +1569,8 @@ Server.prototype.getConnections = function(cb) {
15691569
}
15701570

15711571
// Poll workers
1572-
varleft=this._workers.length;
1573-
vartotal=this._connections;
1572+
letleft=this._workers.length;
1573+
lettotal=this._connections;
15741574

15751575
functiononcount(err,count){
15761576
if(err){
@@ -1582,7 +1582,7 @@ Server.prototype.getConnections = function(cb) {
15821582
if(--left===0)returnend(null,total);
15831583
}
15841584

1585-
for(varn=0;n<this._workers.length;n++){
1585+
for(letn=0;n<this._workers.length;n++){
15861586
this._workers[n].getConnections(oncount);
15871587
}
15881588

@@ -1607,7 +1607,7 @@ Server.prototype.close = function(cb) {
16071607
}
16081608

16091609
if(this._usingWorkers){
1610-
varleft=this._workers.length;
1610+
letleft=this._workers.length;
16111611
constonWorkerClose=()=>{
16121612
if(--left!==0)return;
16131613

@@ -1620,7 +1620,7 @@ Server.prototype.close = function(cb) {
16201620
this._connections++;
16211621

16221622
// Poll workers
1623-
for(varn=0;n<this._workers.length;n++)
1623+
for(letn=0;n<this._workers.length;n++)
16241624
this._workers[n].close(onWorkerClose);
16251625
}else{
16261626
this._emitCloseIfDrained();
@@ -1690,11 +1690,11 @@ Server.prototype.unref = function() {
16901690
returnthis;
16911691
};
16921692

1693-
var_setSimultaneousAccepts;
1694-
varwarnSimultaneousAccepts=true;
1693+
let_setSimultaneousAccepts;
1694+
letwarnSimultaneousAccepts=true;
16951695

16961696
if(process.platform==='win32'){
1697-
varsimultaneousAccepts;
1697+
letsimultaneousAccepts;
16981698

16991699
_setSimultaneousAccepts=function(handle){
17001700
if(warnSimultaneousAccepts){

0 commit comments

Comments
 (0)