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 authored and Anna Henningsen committed 2019-01-14 13:58:05 +01:00
1 parent 901d3d0959
commit 3350230e20
17 files changed
+89 -96

No files matched your search

+6 -5
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
};
}
}
@@ -291,7 +292,7 @@ function request(...args) {
}
if (args[0] && typeof args[0] !== 'function') {
options = util._extend(options, args.shift());
Object.assign(options, args.shift());
}
options._defaultAgent = module.exports.globalAgent;