net: use object destructuring
PR-URL: https://github.com/nodejs/node/pull/20959 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
35858bb98e
commit
a69a29da10
15
lib/net.js
15
lib/net.js
@ -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,
|
||||
@ -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;
|
||||
@ -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();
|
||||
@ -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();
|
||||
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user