diff --git a/benchmark/misc/util-extend-vs-object-assign.js b/benchmark/misc/util-extend-vs-object-assign.js deleted file mode 100644 index e2ac0a5417e489..00000000000000 --- a/benchmark/misc/util-extend-vs-object-assign.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const util = require('util'); - -const bench = common.createBenchmark(main, { - type: ['extend', 'assign'], - n: [10e4], -}); - -function main({ n, type }) { - let fn; - if (type === 'extend') { - fn = util._extend; - } else if (type === 'assign') { - fn = Object.assign; - } - - // Force-optimize the method to test so that the benchmark doesn't - // get disrupted by the optimizer kicking in halfway through. - for (let i = 0; i < type.length * 10; i += 1) - fn({}, process.env); - - const obj = new Proxy({}, { set: function(a, b, c) { return true; } }); - - bench.start(); - for (let j = 0; j < n; j += 1) - fn(obj, process.env); - bench.end(n); -} diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 95a237326f7f49..8a0d7584f11842 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -1540,6 +1540,9 @@ npx codemod@latest @nodejs/util-log-to-console-log -Type: Runtime +Type: End-of-Life The [`util._extend()`][] API is deprecated because it's an unmaintained legacy API that was exposed to user land by accident. diff --git a/lib/util.js b/lib/util.js index 7c75615e5c70da..7802f70cfc94ac 100644 --- a/lib/util.js +++ b/lib/util.js @@ -236,26 +236,6 @@ function inherits(ctor, superCtor) { ObjectSetPrototypeOf(ctor.prototype, superCtor.prototype); } -/** - * @deprecated since v6.0.0 - * @template T - * @template S - * @param {T} target - * @param {S} source - * @returns {(T & S) | null} - */ -function _extend(target, source) { - // Don't do anything if source isn't an object - if (source === null || typeof source !== 'object') return target; - - const keys = ObjectKeys(source); - let i = keys.length; - while (i--) { - target[keys[i]] = source[keys[i]]; - } - return target; -} - const callbackifyOnRejected = (reason, cb) => { // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M). // Because `null` is a special error value in callbacks which means "no error @@ -468,9 +448,6 @@ function deprecate(fn, msg, code, { modifyPrototype } = {}) { module.exports = { _errnoException, _exceptionWithHostPort, - _extend: internalDeprecate(_extend, - 'The `util._extend` API is deprecated. Please use Object.assign() instead.', - 'DEP0060'), callbackify, debug: debuglog, debuglog, diff --git a/test/fixtures/tls-connect.js b/test/fixtures/tls-connect.js index 51c0b328e97e27..107bdf87bd4a8d 100644 --- a/test/fixtures/tls-connect.js +++ b/test/fixtures/tls-connect.js @@ -57,7 +57,7 @@ exports.connect = function connect(options, callback) { }).listen(0, function() { server.server = this; - const optClient = util._extend({ + const optClient = Object.assign({ port: this.address().port, }, options.client); diff --git a/test/parallel/test-util.js b/test/parallel/test-util.js index 1ecddc829a0fdb..e544a2c07c6d88 100644 --- a/test/parallel/test-util.js +++ b/test/parallel/test-util.js @@ -40,15 +40,6 @@ assert.strictEqual(util.isArray(/regexp/), false); assert.strictEqual(util.isArray(new Error()), false); assert.strictEqual(util.isArray({ __proto__: Array.prototype }), false); -// _extend -assert.deepStrictEqual(util._extend({ a: 1 }), { a: 1 }); -assert.deepStrictEqual(util._extend({ a: 1 }, []), { a: 1 }); -assert.deepStrictEqual(util._extend({ a: 1 }, null), { a: 1 }); -assert.deepStrictEqual(util._extend({ a: 1 }, true), { a: 1 }); -assert.deepStrictEqual(util._extend({ a: 1 }, false), { a: 1 }); -assert.deepStrictEqual(util._extend({ a: 1 }, { b: 2 }), { a: 1, b: 2 }); -assert.deepStrictEqual(util._extend({ a: 1, b: 2 }, { b: 3 }), { a: 1, b: 3 }); - assert.strictEqual(util.toUSVString('string\ud801'), 'string\ufffd'); {