Skip to content

Commit

Permalink
net: use object destructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
starkwang committed May 27, 2018
1 parent 468ab45 commit c43fca8
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 c43fca8

Please sign in to comment.