Skip to content

Commit 46d1025

Browse files
starkwangaddaleax
authored andcommitted
net: use object destructuring
PR-URL: #20959 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent d4787cf commit 46d1025

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

‎lib/net.js‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ const kLastWriteQueueSize = Symbol('lastWriteQueueSize');
8282
letcluster;
8383
letdns;
8484

85-
consterrnoException=errors.errnoException;
86-
constexceptionWithHostPort=errors.exceptionWithHostPort;
85+
const{ errnoException, exceptionWithHostPort }=errors;
8786

8887
const{
8988
kTimeout,
@@ -244,7 +243,7 @@ function Socket(options) {
244243

245244
options.readable=options.readable||false;
246245
options.writable=options.writable||false;
247-
constallowHalfOpen=options.allowHalfOpen;
246+
const{allowHalfOpen }=options;
248247

249248
// Prevent the "no-half-open enforcer" from being inherited from `Duplex`.
250249
options.allowHalfOpen=true;
@@ -259,7 +258,7 @@ function Socket(options) {
259258
this._handle=options.handle;// private
260259
this[async_id_symbol]=getNewAsyncId(this._handle);
261260
}elseif(options.fd!==undefined){
262-
constfd=options.fd;
261+
const{fd }=options;
263262
this._handle=createHandle(fd,false);
264263
this._handle.open(fd);
265264
this[async_id_symbol]=this._handle.getAsyncId();
@@ -434,7 +433,7 @@ Socket.prototype._onTimeout = function() {
434433
if(lastWriteQueueSize>0&&handle){
435434
// `lastWriteQueueSize !== writeQueueSize` means there is
436435
// an active write in progress, so we suppress the timeout.
437-
constwriteQueueSize=handle.writeQueueSize;
436+
const{writeQueueSize }=handle;
438437
if(lastWriteQueueSize!==writeQueueSize){
439438
this[kLastWriteQueueSize]=writeQueueSize;
440439
this._unrefTimer();
@@ -956,7 +955,7 @@ Socket.prototype.connect = function(...args) {
956955
this._sockname=null;
957956
}
958957

959-
constpath=options.path;
958+
const{path }=options;
960959
varpipe=!!path;
961960
debug('pipe',pipe,path);
962961

@@ -991,10 +990,8 @@ Socket.prototype.connect = function(...args) {
991990

992991

993992
functionlookupAndConnect(self,options){
993+
var{ port, localAddress, localPort }=options;
994994
varhost=options.host||'localhost';
995-
varport=options.port;
996-
varlocalAddress=options.localAddress;
997-
varlocalPort=options.localPort;
998995

999996
if(localAddress&&!isIP(localAddress)){
1000997
thrownewERR_INVALID_IP_ADDRESS(localAddress);

0 commit comments

Comments
 (0)