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:
Ruben Bridgewater
2018-12-18 03:15:57 +01:00
parent 4b7a530f2b
commit d4c91f2814
17 changed files with 89 additions and 97 deletions

View File

@@ -46,7 +46,7 @@ function Server(opts, requestListener) {
requestListener = opts;
opts = undefined;
}
opts = util._extend({}, opts);
opts = { ...opts };
if (!opts.ALPNProtocols) {
// 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);
if (session) {
debug('reuse session for %j', options._agentKey);
options = util._extend({
session: session
}, options);
options = {
session,
...options
};
}
}
@@ -292,7 +293,7 @@ function request(...args) {
}
if (args[0] && typeof args[0] !== 'function') {
options = util._extend(options, args.shift());
Object.assign(options, args.shift());
}
options._defaultAgent = globalAgent;