Skip to content

Commit

Permalink
net: use object destructuring
Browse files Browse the repository at this point in the history
PR-URL: #20959
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
starkwang authored and addaleax committed Jun 1, 2018
1 parent d4787cf commit 46d1025
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/net.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ const kLastWriteQueueSize = Symbol('lastWriteQueueSize');
let cluster;
let dns;

const errnoException = errors.errnoException;
const exceptionWithHostPort = errors.exceptionWithHostPort;
const { errnoException, exceptionWithHostPort } = errors;

const {
kTimeout,
Expand Down Expand Up @@ -244,7 +243,7 @@ function Socket(options) {

options.readable = options.readable || false;
options.writable = options.writable || false;
const allowHalfOpen = options.allowHalfOpen;
const { allowHalfOpen } = options;

// Prevent the "no-half-open enforcer" from being inherited from `Duplex`.
options.allowHalfOpen = true;
Expand All @@ -259,7 +258,7 @@ function Socket(options) {
this._handle = options.handle; // private
this[async_id_symbol] = getNewAsyncId(this._handle);
} else if (options.fd !== undefined) {
const fd = options.fd;
const { fd } = options;
this._handle = createHandle(fd, false);
this._handle.open(fd);
this[async_id_symbol] = this._handle.getAsyncId();
Expand Down Expand Up @@ -434,7 +433,7 @@ Socket.prototype._onTimeout = function() {
if (lastWriteQueueSize > 0 && handle) {
// `lastWriteQueueSize !== writeQueueSize` means there is
// an active write in progress, so we suppress the timeout.
const writeQueueSize = handle.writeQueueSize;
const { writeQueueSize } = handle;
if (lastWriteQueueSize !== writeQueueSize) {
this[kLastWriteQueueSize] = writeQueueSize;
this._unrefTimer();
Expand Down Expand Up @@ -956,7 +955,7 @@ Socket.prototype.connect = function(...args) {
this._sockname = null;
}

const path = options.path;
const { path } = options;
var pipe = !!path;
debug('pipe', pipe, path);

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


function lookupAndConnect(self, options) {
var { port, localAddress, localPort } = options;
var host = options.host || 'localhost';
var port = options.port;
var localAddress = options.localAddress;
var localPort = options.localPort;

if (localAddress && !isIP(localAddress)) {
throw new ERR_INVALID_IP_ADDRESS(localAddress);
Expand Down

0 comments on commit 46d1025

Please sign in to comment.