Skip to content

Commit ac97a53

Browse files
marco-ippolitonodejs-github-bot
authored andcommittedMay 6, 2024
util: move util._extend to eol
PR-URL: #52744 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Ulises Gascón <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent bbace72 commit ac97a53

File tree

7 files changed

+7
-93
lines changed

7 files changed

+7
-93
lines changed
 

‎benchmark/es/spread-assign.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
'use strict';
22

33
const common = require('../common.js');
4-
const util = require('util');
54

65
const bench = common.createBenchmark(main, {
7-
method: ['spread', 'assign', '_extend'],
6+
method: ['spread', 'assign'],
87
count: [5, 10, 20],
98
n: [1e6],
109
});
@@ -18,12 +17,6 @@ function main({ n, context, count, rest, method }) {
1817
let obj;
1918

2019
switch (method) {
21-
case '_extend':
22-
bench.start();
23-
for (let i = 0; i < n; i++)
24-
obj = util._extend({}, src);
25-
bench.end(n);
26-
break;
2720
case 'assign':
2821
bench.start();
2922
for (let i = 0; i < n; i++)

‎benchmark/misc/util-extend-vs-object-assign.js

-30
This file was deleted.

‎doc/api/deprecations.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,9 @@ requirements and complexity of your application.
13631363

13641364
<!-- YAML
13651365
changes:
1366+
- version: REPLACEME
1367+
pr-url: https://github.com/nodejs/node/pull/52744
1368+
description: End-of-Life deprecation.
13661369
- version: v22.0.0
13671370
pr-url: https://github.com/nodejs/node/pull/50488
13681371
description: Runtime deprecation.
@@ -1374,9 +1377,9 @@ changes:
13741377
description: Documentation-only deprecation.
13751378
-->
13761379

1377-
Type: Runtime
1380+
Type: End-of-Life
13781381

1379-
The [`util._extend()`][] API is deprecated because it's an unmaintained
1382+
The `util._extend()` API has been removed because it's an unmaintained
13801383
legacy API that was exposed to user land by accident.
13811384
Please use `target = Object.assign(target, source)` instead.
13821385

@@ -3769,7 +3772,6 @@ is deprecated to better align with recommendations per [NIST SP 800-38D][].
37693772
[`url.format()`]: url.md#urlformaturlobject
37703773
[`url.parse()`]: url.md#urlparseurlstring-parsequerystring-slashesdenotehost
37713774
[`url.resolve()`]: url.md#urlresolvefrom-to
3772-
[`util._extend()`]: util.md#util_extendtarget-source
37733775
[`util.getSystemErrorName()`]: util.md#utilgetsystemerrornameerr
37743776
[`util.inspect()`]: util.md#utilinspectobject-options
37753777
[`util.inspect.custom`]: util.md#utilinspectcustom

‎doc/api/util.md

-19
Original file line numberDiff line numberDiff line change
@@ -2923,24 +2923,6 @@ util.types.isWeakSet(new WeakSet()); // Returns true
29232923
The following APIs are deprecated and should no longer be used. Existing
29242924
applications and modules should be updated to find alternative approaches.
29252925
2926-
### `util._extend(target, source)`
2927-
2928-
<!-- YAML
2929-
added: v0.7.5
2930-
deprecated: v6.0.0
2931-
-->
2932-
2933-
> Stability: 0 - Deprecated: Use [`Object.assign()`][] instead.
2934-
2935-
* `target` {Object}
2936-
* `source` {Object}
2937-
2938-
The `util._extend()` method was never intended to be used outside of internal
2939-
Node.js modules. The community found and used it anyway.
2940-
2941-
It is deprecated and should not be used in new code. JavaScript comes with very
2942-
similar built-in functionality through [`Object.assign()`][].
2943-
29442926
### `util.isArray(object)`
29452927
29462928
<!-- YAML
@@ -3410,7 +3392,6 @@ util.log('Timestamped message.');
34103392
[`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
34113393
[`MIMEparams`]: #class-utilmimeparams
34123394
[`Map`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
3413-
[`Object.assign()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
34143395
[`Object.freeze()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze
34153396
[`Promise`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
34163397
[`Proxy`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy

‎lib/util.js

-23
Original file line numberDiff line numberDiff line change
@@ -299,26 +299,6 @@ function inherits(ctor, superCtor) {
299299
ObjectSetPrototypeOf(ctor.prototype, superCtor.prototype);
300300
}
301301

302-
/**
303-
* @deprecated since v6.0.0
304-
* @template T
305-
* @template S
306-
* @param {T} target
307-
* @param {S} source
308-
* @returns {S extends null ? T : (T & S)}
309-
*/
310-
function _extend(target, source) {
311-
// Don't do anything if source isn't an object
312-
if (source === null || typeof source !== 'object') return target;
313-
314-
const keys = ObjectKeys(source);
315-
let i = keys.length;
316-
while (i--) {
317-
target[keys[i]] = source[keys[i]];
318-
}
319-
return target;
320-
}
321-
322302
const callbackifyOnRejected = (reason, cb) => {
323303
// `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
324304
// Because `null` is a special error value in callbacks which means "no error
@@ -425,9 +405,6 @@ function parseEnv(content) {
425405
module.exports = {
426406
_errnoException,
427407
_exceptionWithHostPort,
428-
_extend: deprecate(_extend,
429-
'The `util._extend` API is deprecated. Please use Object.assign() instead.',
430-
'DEP0060'),
431408
callbackify,
432409
debug: debuglog,
433410
debuglog,

‎test/fixtures/tls-connect.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ exports.connect = function connect(options, callback) {
5757
}).listen(0, function() {
5858
server.server = this;
5959

60-
const optClient = util._extend({
60+
const optClient = Object.assign({
6161
port: this.address().port,
6262
}, options.client);
6363

‎test/parallel/test-util.js

-9
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,6 @@ assert.strictEqual(util.isPrimitive(Symbol('symbol')), true);
102102
assert.strictEqual(util.isBuffer('foo'), false);
103103
assert.strictEqual(util.isBuffer(Buffer.from('foo')), true);
104104

105-
// _extend
106-
assert.deepStrictEqual(util._extend({ a: 1 }), { a: 1 });
107-
assert.deepStrictEqual(util._extend({ a: 1 }, []), { a: 1 });
108-
assert.deepStrictEqual(util._extend({ a: 1 }, null), { a: 1 });
109-
assert.deepStrictEqual(util._extend({ a: 1 }, true), { a: 1 });
110-
assert.deepStrictEqual(util._extend({ a: 1 }, false), { a: 1 });
111-
assert.deepStrictEqual(util._extend({ a: 1 }, { b: 2 }), { a: 1, b: 2 });
112-
assert.deepStrictEqual(util._extend({ a: 1, b: 2 }, { b: 3 }), { a: 1, b: 3 });
113-
114105
// deprecated
115106
assert.strictEqual(util.isBoolean(true), true);
116107
assert.strictEqual(util.isBoolean(false), true);

0 commit comments

Comments
 (0)
Please sign in to comment.