lib: remove internal util._extends()
usage
This removes all internal calls to the deprecated `_extends()` function. It is slower than `Object.assign()` and the object spread notation since V8 6.8 and using the spread notation often also results in shorter code. PR-URL: https://github.com/nodejs/node/pull/25105 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
4b7a530f2b
commit
d4c91f2814
@ -48,7 +48,7 @@ function Agent(options) {
|
|||||||
this.defaultPort = 80;
|
this.defaultPort = 80;
|
||||||
this.protocol = 'http:';
|
this.protocol = 'http:';
|
||||||
|
|
||||||
this.options = util._extend({}, options);
|
this.options = { ...options };
|
||||||
|
|
||||||
// Don't confuse net and make it think that we're connecting to a pipe
|
// Don't confuse net and make it think that we're connecting to a pipe
|
||||||
this.options.path = null;
|
this.options.path = null;
|
||||||
@ -146,8 +146,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */,
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
options = util._extend({}, options);
|
options = { ...options, ...this.options };
|
||||||
util._extend(options, this.options);
|
|
||||||
if (options.socketPath)
|
if (options.socketPath)
|
||||||
options.path = options.socketPath;
|
options.path = options.socketPath;
|
||||||
|
|
||||||
@ -194,8 +193,7 @@ Agent.prototype.addRequest = function addRequest(req, options, port/* legacy */,
|
|||||||
};
|
};
|
||||||
|
|
||||||
Agent.prototype.createSocket = function createSocket(req, options, cb) {
|
Agent.prototype.createSocket = function createSocket(req, options, cb) {
|
||||||
options = util._extend({}, options);
|
options = { ...options, ...this.options };
|
||||||
util._extend(options, this.options);
|
|
||||||
if (options.socketPath)
|
if (options.socketPath)
|
||||||
options.path = options.socketPath;
|
options.path = options.socketPath;
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const util = require('util');
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const url = require('url');
|
const url = require('url');
|
||||||
const assert = require('assert').ok;
|
const assert = require('assert').ok;
|
||||||
@ -93,11 +92,11 @@ function ClientRequest(input, options, cb) {
|
|||||||
|
|
||||||
if (typeof options === 'function') {
|
if (typeof options === 'function') {
|
||||||
cb = options;
|
cb = options;
|
||||||
options = null;
|
options = input || {};
|
||||||
|
} else {
|
||||||
|
options = Object.assign(input || {}, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
options = util._extend(input || {}, options || {});
|
|
||||||
|
|
||||||
var agent = options.agent;
|
var agent = options.agent;
|
||||||
var defaultAgent = options._defaultAgent || Agent.globalAgent;
|
var defaultAgent = options._defaultAgent || Agent.globalAgent;
|
||||||
if (agent === false) {
|
if (agent === false) {
|
||||||
|
@ -282,7 +282,7 @@ function Server(options, requestListener) {
|
|||||||
requestListener = options;
|
requestListener = options;
|
||||||
options = {};
|
options = {};
|
||||||
} else if (options == null || typeof options === 'object') {
|
} else if (options == null || typeof options === 'object') {
|
||||||
options = util._extend({}, options);
|
options = { ...options };
|
||||||
} else {
|
} else {
|
||||||
throw new ERR_INVALID_ARG_TYPE('options', 'object', options);
|
throw new ERR_INVALID_ARG_TYPE('options', 'object', options);
|
||||||
}
|
}
|
||||||
|
@ -1109,9 +1109,9 @@ function SNICallback(servername, callback) {
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
function normalizeConnectArgs(listArgs) {
|
function normalizeConnectArgs(listArgs) {
|
||||||
var args = net._normalizeArgs(listArgs);
|
const args = net._normalizeArgs(listArgs);
|
||||||
var options = args[0];
|
const options = args[0];
|
||||||
var cb = args[1];
|
const cb = args[1];
|
||||||
|
|
||||||
// If args[0] was options, then normalize dealt with it.
|
// If args[0] was options, then normalize dealt with it.
|
||||||
// If args[0] is port, or args[0], args[1] is host, port, we need to
|
// If args[0] is port, or args[0], args[1] is host, port, we need to
|
||||||
@ -1119,12 +1119,12 @@ function normalizeConnectArgs(listArgs) {
|
|||||||
// the host/port/path args that it knows about, not the tls options.
|
// the host/port/path args that it knows about, not the tls options.
|
||||||
// This means that options.host overrides a host arg.
|
// This means that options.host overrides a host arg.
|
||||||
if (listArgs[1] !== null && typeof listArgs[1] === 'object') {
|
if (listArgs[1] !== null && typeof listArgs[1] === 'object') {
|
||||||
util._extend(options, listArgs[1]);
|
Object.assign(options, listArgs[1]);
|
||||||
} else if (listArgs[2] !== null && typeof listArgs[2] === 'object') {
|
} else if (listArgs[2] !== null && typeof listArgs[2] === 'object') {
|
||||||
util._extend(options, listArgs[2]);
|
Object.assign(options, listArgs[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (cb) ? [options, cb] : [options];
|
return cb ? [options, cb] : [options];
|
||||||
}
|
}
|
||||||
|
|
||||||
function onConnectSecure() {
|
function onConnectSecure() {
|
||||||
@ -1205,14 +1205,14 @@ exports.connect = function connect(...args) {
|
|||||||
'certificate verification.');
|
'certificate verification.');
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaults = {
|
options = {
|
||||||
rejectUnauthorized: !allowUnauthorized,
|
rejectUnauthorized: !allowUnauthorized,
|
||||||
ciphers: tls.DEFAULT_CIPHERS,
|
ciphers: tls.DEFAULT_CIPHERS,
|
||||||
checkServerIdentity: tls.checkServerIdentity,
|
checkServerIdentity: tls.checkServerIdentity,
|
||||||
minDHSize: 1024
|
minDHSize: 1024,
|
||||||
|
...options
|
||||||
};
|
};
|
||||||
|
|
||||||
options = util._extend(defaults, options || {});
|
|
||||||
if (!options.keepAlive)
|
if (!options.keepAlive)
|
||||||
options.singleUse = true;
|
options.singleUse = true;
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ exports.fork = function fork(modulePath /* , args, options */) {
|
|||||||
throw new ERR_INVALID_ARG_VALUE(`arguments[${pos}]`, arguments[pos]);
|
throw new ERR_INVALID_ARG_VALUE(`arguments[${pos}]`, arguments[pos]);
|
||||||
}
|
}
|
||||||
|
|
||||||
options = util._extend({}, arguments[pos++]);
|
options = { ...arguments[pos++] };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare arguments for fork:
|
// Prepare arguments for fork:
|
||||||
@ -176,20 +176,12 @@ Object.defineProperty(exports.exec, util.promisify.custom, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
exports.execFile = function execFile(file /* , args, options, callback */) {
|
exports.execFile = function execFile(file /* , args, options, callback */) {
|
||||||
var args = [];
|
let args = [];
|
||||||
var callback;
|
let callback;
|
||||||
var options = {
|
let options;
|
||||||
encoding: 'utf8',
|
|
||||||
timeout: 0,
|
|
||||||
maxBuffer: 200 * 1024,
|
|
||||||
killSignal: 'SIGTERM',
|
|
||||||
cwd: null,
|
|
||||||
env: null,
|
|
||||||
shell: false
|
|
||||||
};
|
|
||||||
|
|
||||||
// Parse the optional positional parameters.
|
// Parse the optional positional parameters.
|
||||||
var pos = 1;
|
let pos = 1;
|
||||||
if (pos < arguments.length && Array.isArray(arguments[pos])) {
|
if (pos < arguments.length && Array.isArray(arguments[pos])) {
|
||||||
args = arguments[pos++];
|
args = arguments[pos++];
|
||||||
} else if (pos < arguments.length && arguments[pos] == null) {
|
} else if (pos < arguments.length && arguments[pos] == null) {
|
||||||
@ -197,7 +189,7 @@ exports.execFile = function execFile(file /* , args, options, callback */) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pos < arguments.length && typeof arguments[pos] === 'object') {
|
if (pos < arguments.length && typeof arguments[pos] === 'object') {
|
||||||
util._extend(options, arguments[pos++]);
|
options = arguments[pos++];
|
||||||
} else if (pos < arguments.length && arguments[pos] == null) {
|
} else if (pos < arguments.length && arguments[pos] == null) {
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
@ -210,6 +202,17 @@ exports.execFile = function execFile(file /* , args, options, callback */) {
|
|||||||
throw new ERR_INVALID_ARG_VALUE('args', arguments[pos]);
|
throw new ERR_INVALID_ARG_VALUE('args', arguments[pos]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
options = {
|
||||||
|
encoding: 'utf8',
|
||||||
|
timeout: 0,
|
||||||
|
maxBuffer: 200 * 1024,
|
||||||
|
killSignal: 'SIGTERM',
|
||||||
|
cwd: null,
|
||||||
|
env: null,
|
||||||
|
shell: false,
|
||||||
|
...options
|
||||||
|
};
|
||||||
|
|
||||||
// Validate the timeout, if present.
|
// Validate the timeout, if present.
|
||||||
validateTimeout(options.timeout);
|
validateTimeout(options.timeout);
|
||||||
|
|
||||||
@ -580,7 +583,7 @@ function spawnSync(/* file, args, options */) {
|
|||||||
options.stdio = _validateStdio(options.stdio || 'pipe', true).stdio;
|
options.stdio = _validateStdio(options.stdio || 'pipe', true).stdio;
|
||||||
|
|
||||||
if (options.input) {
|
if (options.input) {
|
||||||
var stdin = options.stdio[0] = util._extend({}, options.stdio[0]);
|
var stdin = options.stdio[0] = { ...options.stdio[0] };
|
||||||
stdin.input = options.input;
|
stdin.input = options.input;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,7 +591,7 @@ function spawnSync(/* file, args, options */) {
|
|||||||
for (var i = 0; i < options.stdio.length; i++) {
|
for (var i = 0; i < options.stdio.length; i++) {
|
||||||
var input = options.stdio[i] && options.stdio[i].input;
|
var input = options.stdio[i] && options.stdio[i].input;
|
||||||
if (input != null) {
|
if (input != null) {
|
||||||
var pipe = options.stdio[i] = util._extend({}, options.stdio[i]);
|
var pipe = options.stdio[i] = { ...options.stdio[i] };
|
||||||
if (isArrayBufferView(input)) {
|
if (isArrayBufferView(input)) {
|
||||||
pipe.input = input;
|
pipe.input = input;
|
||||||
} else if (typeof input === 'string') {
|
} else if (typeof input === 'string') {
|
||||||
|
@ -343,11 +343,9 @@ Domain.prototype.run = function(fn) {
|
|||||||
function intercepted(_this, self, cb, fnargs) {
|
function intercepted(_this, self, cb, fnargs) {
|
||||||
if (fnargs[0] && fnargs[0] instanceof Error) {
|
if (fnargs[0] && fnargs[0] instanceof Error) {
|
||||||
var er = fnargs[0];
|
var er = fnargs[0];
|
||||||
util._extend(er, {
|
er.domainBound = cb;
|
||||||
domainBound: cb,
|
er.domainThrown = false;
|
||||||
domainThrown: false,
|
er.domain = self;
|
||||||
domain: self
|
|
||||||
});
|
|
||||||
self.emit('error', er);
|
self.emit('error', er);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
18
lib/fs.js
18
lib/fs.js
@ -39,7 +39,6 @@ const {
|
|||||||
O_SYMLINK
|
O_SYMLINK
|
||||||
} = constants;
|
} = constants;
|
||||||
|
|
||||||
const { _extend } = require('util');
|
|
||||||
const pathModule = require('path');
|
const pathModule = require('path');
|
||||||
const { isArrayBufferView } = require('internal/util/types');
|
const { isArrayBufferView } = require('internal/util/types');
|
||||||
const binding = internalBinding('fs');
|
const binding = internalBinding('fs');
|
||||||
@ -1325,21 +1324,20 @@ function watchFile(filename, options, listener) {
|
|||||||
filename = pathModule.resolve(filename);
|
filename = pathModule.resolve(filename);
|
||||||
let stat;
|
let stat;
|
||||||
|
|
||||||
const defaults = {
|
if (options === null || typeof options !== 'object') {
|
||||||
|
listener = options;
|
||||||
|
options = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
options = {
|
||||||
// Poll interval in milliseconds. 5007 is what libev used to use. It's
|
// Poll interval in milliseconds. 5007 is what libev used to use. It's
|
||||||
// a little on the slow side but let's stick with it for now to keep
|
// a little on the slow side but let's stick with it for now to keep
|
||||||
// behavioral changes to a minimum.
|
// behavioral changes to a minimum.
|
||||||
interval: 5007,
|
interval: 5007,
|
||||||
persistent: true
|
persistent: true,
|
||||||
|
...options
|
||||||
};
|
};
|
||||||
|
|
||||||
if (options !== null && typeof options === 'object') {
|
|
||||||
options = _extend(defaults, options);
|
|
||||||
} else {
|
|
||||||
listener = options;
|
|
||||||
options = defaults;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof listener !== 'function') {
|
if (typeof listener !== 'function') {
|
||||||
throw new ERR_INVALID_ARG_TYPE('listener', 'Function', listener);
|
throw new ERR_INVALID_ARG_TYPE('listener', 'Function', listener);
|
||||||
}
|
}
|
||||||
|
11
lib/https.js
11
lib/https.js
@ -46,7 +46,7 @@ function Server(opts, requestListener) {
|
|||||||
requestListener = opts;
|
requestListener = opts;
|
||||||
opts = undefined;
|
opts = undefined;
|
||||||
}
|
}
|
||||||
opts = util._extend({}, opts);
|
opts = { ...opts };
|
||||||
|
|
||||||
if (!opts.ALPNProtocols) {
|
if (!opts.ALPNProtocols) {
|
||||||
// http/1.0 is not defined as Protocol IDs in IANA
|
// http/1.0 is not defined as Protocol IDs in IANA
|
||||||
@ -110,9 +110,10 @@ function createConnection(port, host, options) {
|
|||||||
const session = this._getSession(options._agentKey);
|
const session = this._getSession(options._agentKey);
|
||||||
if (session) {
|
if (session) {
|
||||||
debug('reuse session for %j', options._agentKey);
|
debug('reuse session for %j', options._agentKey);
|
||||||
options = util._extend({
|
options = {
|
||||||
session: session
|
session,
|
||||||
}, options);
|
...options
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +293,7 @@ function request(...args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args[0] && typeof args[0] !== 'function') {
|
if (args[0] && typeof args[0] !== 'function') {
|
||||||
options = util._extend(options, args.shift());
|
Object.assign(options, args.shift());
|
||||||
}
|
}
|
||||||
|
|
||||||
options._defaultAgent = globalAgent;
|
options._defaultAgent = globalAgent;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const util = require('util');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const { owner_symbol } = require('internal/async_hooks').symbols;
|
const { owner_symbol } = require('internal/async_hooks').symbols;
|
||||||
@ -71,11 +70,12 @@ cluster._getServer = function(obj, options, cb) {
|
|||||||
|
|
||||||
indexes.set(indexesKey, index);
|
indexes.set(indexesKey, index);
|
||||||
|
|
||||||
const message = util._extend({
|
const message = {
|
||||||
act: 'queryServer',
|
act: 'queryServer',
|
||||||
index,
|
index,
|
||||||
data: null
|
data: null,
|
||||||
}, options);
|
...options
|
||||||
|
};
|
||||||
|
|
||||||
message.address = address;
|
message.address = address;
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ function rr(message, indexesKey, cb) {
|
|||||||
|
|
||||||
function getsockname(out) {
|
function getsockname(out) {
|
||||||
if (key)
|
if (key)
|
||||||
util._extend(out, message.sockname);
|
Object.assign(out, message.sockname);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { fork } = require('child_process');
|
const { fork } = require('child_process');
|
||||||
const util = require('util');
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
const RoundRobinHandle = require('internal/cluster/round_robin_handle');
|
const RoundRobinHandle = require('internal/cluster/round_robin_handle');
|
||||||
@ -47,14 +46,14 @@ if (schedulingPolicy === undefined) {
|
|||||||
cluster.schedulingPolicy = schedulingPolicy;
|
cluster.schedulingPolicy = schedulingPolicy;
|
||||||
|
|
||||||
cluster.setupMaster = function(options) {
|
cluster.setupMaster = function(options) {
|
||||||
var settings = {
|
const settings = {
|
||||||
args: process.argv.slice(2),
|
args: process.argv.slice(2),
|
||||||
exec: process.argv[1],
|
exec: process.argv[1],
|
||||||
execArgv: process.execArgv,
|
execArgv: process.execArgv,
|
||||||
silent: false
|
silent: false,
|
||||||
|
...cluster.settings,
|
||||||
|
...options
|
||||||
};
|
};
|
||||||
util._extend(settings, cluster.settings);
|
|
||||||
util._extend(settings, options || {});
|
|
||||||
|
|
||||||
// Tell V8 to write profile data for each process to a separate file.
|
// Tell V8 to write profile data for each process to a separate file.
|
||||||
// Without --logfile=v8-%p.log, everything ends up in a single, unusable
|
// Without --logfile=v8-%p.log, everything ends up in a single, unusable
|
||||||
@ -101,15 +100,12 @@ function setupSettingsNT(settings) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createWorkerProcess(id, env) {
|
function createWorkerProcess(id, env) {
|
||||||
const workerEnv = util._extend({}, process.env);
|
const workerEnv = { ...process.env, ...env, NODE_UNIQUE_ID: `${id}` };
|
||||||
const execArgv = cluster.settings.execArgv.slice();
|
const execArgv = cluster.settings.execArgv.slice();
|
||||||
const debugArgRegex = /--inspect(?:-brk|-port)?|--debug-port/;
|
const debugArgRegex = /--inspect(?:-brk|-port)?|--debug-port/;
|
||||||
const nodeOptions = process.env.NODE_OPTIONS ?
|
const nodeOptions = process.env.NODE_OPTIONS ?
|
||||||
process.env.NODE_OPTIONS : '';
|
process.env.NODE_OPTIONS : '';
|
||||||
|
|
||||||
util._extend(workerEnv, env);
|
|
||||||
workerEnv.NODE_UNIQUE_ID = '' + id;
|
|
||||||
|
|
||||||
if (execArgv.some((arg) => arg.match(debugArgRegex)) ||
|
if (execArgv.some((arg) => arg.match(debugArgRegex)) ||
|
||||||
nodeOptions.match(debugArgRegex)) {
|
nodeOptions.match(debugArgRegex)) {
|
||||||
let inspectPort;
|
let inspectPort;
|
||||||
@ -315,17 +311,18 @@ function queryServer(worker, message) {
|
|||||||
|
|
||||||
// Set custom server data
|
// Set custom server data
|
||||||
handle.add(worker, (errno, reply, handle) => {
|
handle.add(worker, (errno, reply, handle) => {
|
||||||
reply = util._extend({
|
const { data } = handles.get(key);
|
||||||
errno: errno,
|
|
||||||
key: key,
|
|
||||||
ack: message.seq,
|
|
||||||
data: handles.get(key).data
|
|
||||||
}, reply);
|
|
||||||
|
|
||||||
if (errno)
|
if (errno)
|
||||||
handles.delete(key); // Gives other workers a chance to retry.
|
handles.delete(key); // Gives other workers a chance to retry.
|
||||||
|
|
||||||
send(worker, reply, handle);
|
send(worker, {
|
||||||
|
errno,
|
||||||
|
key,
|
||||||
|
ack: message.seq,
|
||||||
|
data,
|
||||||
|
...reply
|
||||||
|
}, handle);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const util = require('util');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
sendHelper,
|
sendHelper,
|
||||||
@ -14,12 +13,11 @@ function sendHelper(proc, message, handle, cb) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Mark message as internal. See INTERNAL_PREFIX in lib/child_process.js
|
// Mark message as internal. See INTERNAL_PREFIX in lib/child_process.js
|
||||||
message = util._extend({ cmd: 'NODE_CLUSTER' }, message);
|
message = { cmd: 'NODE_CLUSTER', ...message, seq };
|
||||||
|
|
||||||
if (typeof cb === 'function')
|
if (typeof cb === 'function')
|
||||||
callbacks.set(seq, cb);
|
callbacks.set(seq, cb);
|
||||||
|
|
||||||
message.seq = seq;
|
|
||||||
seq += 1;
|
seq += 1;
|
||||||
return proc.send(message, handle);
|
return proc.send(message, handle);
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ function getOptions(options, defaultOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof options === 'string') {
|
if (typeof options === 'string') {
|
||||||
defaultOptions = util._extend({}, defaultOptions);
|
defaultOptions = { ...defaultOptions };
|
||||||
defaultOptions.encoding = options;
|
defaultOptions.encoding = options;
|
||||||
options = defaultOptions;
|
options = defaultOptions;
|
||||||
} else if (typeof options !== 'object') {
|
} else if (typeof options !== 'object') {
|
||||||
|
@ -24,12 +24,13 @@ function createRepl(env, opts, cb) {
|
|||||||
cb = opts;
|
cb = opts;
|
||||||
opts = null;
|
opts = null;
|
||||||
}
|
}
|
||||||
opts = util._extend({
|
opts = {
|
||||||
ignoreUndefined: false,
|
ignoreUndefined: false,
|
||||||
terminal: process.stdout.isTTY,
|
terminal: process.stdout.isTTY,
|
||||||
useGlobal: true,
|
useGlobal: true,
|
||||||
breakEvalOnSigint: true
|
breakEvalOnSigint: true,
|
||||||
}, opts);
|
...opts
|
||||||
|
};
|
||||||
|
|
||||||
if (parseInt(env.NODE_NO_READLINE)) {
|
if (parseInt(env.NODE_NO_READLINE)) {
|
||||||
opts.terminal = false;
|
opts.terminal = false;
|
||||||
|
@ -193,7 +193,7 @@ class URLSearchParams {
|
|||||||
return ctx.stylize('[Object]', 'special');
|
return ctx.stylize('[Object]', 'special');
|
||||||
|
|
||||||
var separator = ', ';
|
var separator = ', ';
|
||||||
var innerOpts = util._extend({}, ctx);
|
var innerOpts = { ...ctx };
|
||||||
if (recurseTimes !== null) {
|
if (recurseTimes !== null) {
|
||||||
innerOpts.depth = recurseTimes - 1;
|
innerOpts.depth = recurseTimes - 1;
|
||||||
}
|
}
|
||||||
@ -382,12 +382,13 @@ Object.defineProperties(URL.prototype, {
|
|||||||
value: function format(options) {
|
value: function format(options) {
|
||||||
if (options && typeof options !== 'object')
|
if (options && typeof options !== 'object')
|
||||||
throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
|
throw new ERR_INVALID_ARG_TYPE('options', 'Object', options);
|
||||||
options = util._extend({
|
options = {
|
||||||
fragment: true,
|
fragment: true,
|
||||||
unicode: false,
|
unicode: false,
|
||||||
search: true,
|
search: true,
|
||||||
auth: true
|
auth: true,
|
||||||
}, options);
|
...options
|
||||||
|
};
|
||||||
const ctx = this[context];
|
const ctx = this[context];
|
||||||
var ret = ctx.scheme;
|
var ret = ctx.scheme;
|
||||||
if (ctx.host !== null) {
|
if (ctx.host !== null) {
|
||||||
@ -1202,7 +1203,7 @@ defineIDLClass(URLSearchParamsIteratorPrototype, 'URLSearchParams Iterator', {
|
|||||||
if (typeof recurseTimes === 'number' && recurseTimes < 0)
|
if (typeof recurseTimes === 'number' && recurseTimes < 0)
|
||||||
return ctx.stylize('[Object]', 'special');
|
return ctx.stylize('[Object]', 'special');
|
||||||
|
|
||||||
const innerOpts = util._extend({}, ctx);
|
const innerOpts = { ...ctx };
|
||||||
if (recurseTimes !== null) {
|
if (recurseTimes !== null) {
|
||||||
innerOpts.depth = recurseTimes - 1;
|
innerOpts.depth = recurseTimes - 1;
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ function Socket(options) {
|
|||||||
if (typeof options === 'number')
|
if (typeof options === 'number')
|
||||||
options = { fd: options }; // Legacy interface.
|
options = { fd: options }; // Legacy interface.
|
||||||
else
|
else
|
||||||
options = util._extend({}, options);
|
options = { ...options };
|
||||||
|
|
||||||
options.readable = options.readable || false;
|
options.readable = options.readable || false;
|
||||||
options.writable = options.writable || false;
|
options.writable = options.writable || false;
|
||||||
|
11
lib/tty.js
11
lib/tty.js
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { inherits, _extend } = require('util');
|
const { inherits } = require('util');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const { TTY, isTTY } = internalBinding('tty_wrap');
|
const { TTY, isTTY } = internalBinding('tty_wrap');
|
||||||
const errors = require('internal/errors');
|
const errors = require('internal/errors');
|
||||||
@ -47,14 +47,13 @@ function ReadStream(fd, options) {
|
|||||||
throw new ERR_TTY_INIT_FAILED(ctx);
|
throw new ERR_TTY_INIT_FAILED(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
options = _extend({
|
net.Socket.call(this, {
|
||||||
highWaterMark: 0,
|
highWaterMark: 0,
|
||||||
readable: true,
|
readable: true,
|
||||||
writable: false,
|
writable: false,
|
||||||
handle: tty
|
handle: tty,
|
||||||
}, options);
|
...options
|
||||||
|
});
|
||||||
net.Socket.call(this, options);
|
|
||||||
|
|
||||||
this.isRaw = false;
|
this.isRaw = false;
|
||||||
this.isTTY = true;
|
this.isTTY = true;
|
||||||
|
@ -30,7 +30,6 @@ const {
|
|||||||
const Transform = require('_stream_transform');
|
const Transform = require('_stream_transform');
|
||||||
const {
|
const {
|
||||||
deprecate,
|
deprecate,
|
||||||
_extend,
|
|
||||||
types: {
|
types: {
|
||||||
isAnyArrayBuffer,
|
isAnyArrayBuffer,
|
||||||
isArrayBufferView
|
isArrayBufferView
|
||||||
@ -233,7 +232,7 @@ function ZlibBase(opts, mode, handle, { flush, finishFlush, fullFlush }) {
|
|||||||
Z_NO_FLUSH, Z_BLOCK, finishFlush);
|
Z_NO_FLUSH, Z_BLOCK, finishFlush);
|
||||||
|
|
||||||
if (opts.encoding || opts.objectMode || opts.writableObjectMode) {
|
if (opts.encoding || opts.objectMode || opts.writableObjectMode) {
|
||||||
opts = _extend({}, opts);
|
opts = { ...opts };
|
||||||
opts.encoding = null;
|
opts.encoding = null;
|
||||||
opts.objectMode = false;
|
opts.objectMode = false;
|
||||||
opts.writableObjectMode = false;
|
opts.writableObjectMode = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user