Skip to content

Commit 46d1025

Browse files
starkwangaddaleax
authored andcommitted
net: use object destructuring
PR-URL: #20959 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent d4787cf commit 46d1025

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

lib/net.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ const kLastWriteQueueSize = Symbol('lastWriteQueueSize');
8282
let cluster;
8383
let dns;
8484

85-
const errnoException = errors.errnoException;
86-
const exceptionWithHostPort = 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-
const allowHalfOpen = 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
} else if (options.fd !== undefined) {
262-
const fd = 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-
const writeQueueSize = 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-
const path = options.path;
958+
const { path } = options;
960959
var pipe = !!path;
961960
debug('pipe', pipe, path);
962961

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

992991

993992
function lookupAndConnect(self, options) {
993+
var { port, localAddress, localPort } = options;
994994
var host = options.host || 'localhost';
995-
var port = options.port;
996-
var localAddress = options.localAddress;
997-
var localPort = options.localPort;
998995

999996
if (localAddress && !isIP(localAddress)) {
1000997
throw new ERR_INVALID_IP_ADDRESS(localAddress);

0 commit comments

Comments
 (0)