Skip to content

Commit 900d79c

Browse files
marco-ippolitonodejs-github-bot
authored andcommitted
doc: add migration paths for deprecated utils
PR-URL: #50488 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io> Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent e96cd25 commit 900d79c

File tree

2 files changed

+40
-15
lines changed

2 files changed

+40
-15
lines changed

doc/api/deprecations.md

+39-14
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,8 @@ changes:
10051005

10061006
Type: Runtime
10071007

1008-
The [`util.isBoolean()`][] API is deprecated.
1008+
The [`util.isBoolean()`][] API is deprecated. Please use
1009+
`typeof arg === 'boolean'` instead.
10091010

10101011
### DEP0046: `util.isBuffer()`
10111012

@@ -1052,7 +1053,8 @@ changes:
10521053

10531054
Type: Runtime
10541055

1055-
The [`util.isDate()`][] API is deprecated.
1056+
The [`util.isDate()`][] API is deprecated. Please use
1057+
`arg instanceof Date` instead.
10561058

10571059
### DEP0048: `util.isError()`
10581060

@@ -1100,7 +1102,8 @@ changes:
11001102

11011103
Type: Runtime
11021104

1103-
The [`util.isFunction()`][] API is deprecated.
1105+
The [`util.isFunction()`][] API is deprecated. Please use
1106+
`typeof arg === 'function'` instead.
11041107

11051108
### DEP0050: `util.isNull()`
11061109

@@ -1123,7 +1126,8 @@ changes:
11231126

11241127
Type: Runtime
11251128

1126-
The [`util.isNull()`][] API is deprecated.
1129+
The [`util.isNull()`][] API is deprecated. Please use
1130+
`arg === null` instead.
11271131

11281132
### DEP0051: `util.isNullOrUndefined()`
11291133

@@ -1146,7 +1150,8 @@ changes:
11461150

11471151
Type: Runtime
11481152

1149-
The [`util.isNullOrUndefined()`][] API is deprecated.
1153+
The [`util.isNullOrUndefined()`][] API is deprecated. Please use
1154+
`arg === null || arg === undefined` instead.
11501155

11511156
### DEP0052: `util.isNumber()`
11521157

@@ -1169,7 +1174,8 @@ changes:
11691174

11701175
Type: Runtime
11711176

1172-
The [`util.isNumber()`][] API is deprecated.
1177+
The [`util.isNumber()`][] API is deprecated. Please use
1178+
`typeof arg === 'number'` instead.
11731179

11741180
### DEP0053: `util.isObject()`
11751181

@@ -1192,7 +1198,8 @@ changes:
11921198

11931199
Type: Runtime
11941200

1195-
The [`util.isObject()`][] API is deprecated.
1201+
The [`util.isObject()`][] API is deprecated. Please use
1202+
`arg && typeof arg === 'object'` instead.
11961203

11971204
### DEP0054: `util.isPrimitive()`
11981205

@@ -1215,7 +1222,9 @@ changes:
12151222

12161223
Type: Runtime
12171224

1218-
The [`util.isPrimitive()`][] API is deprecated.
1225+
The [`util.isPrimitive()`][] API is deprecated. Please use
1226+
`arg === null || (typeof arg !=='object' && typeof arg !== 'function')`
1227+
instead.
12191228

12201229
### DEP0055: `util.isRegExp()`
12211230

@@ -1238,7 +1247,8 @@ changes:
12381247

12391248
Type: Runtime
12401249

1241-
The [`util.isRegExp()`][] API is deprecated.
1250+
The [`util.isRegExp()`][] API is deprecated. Please use
1251+
`arg instanceof RegExp` instead.
12421252

12431253
### DEP0056: `util.isString()`
12441254

@@ -1261,7 +1271,8 @@ changes:
12611271

12621272
Type: Runtime
12631273

1264-
The [`util.isString()`][] API is deprecated.
1274+
The [`util.isString()`][] API is deprecated. Please use
1275+
`typeof arg === 'string'` instead.
12651276

12661277
### DEP0057: `util.isSymbol()`
12671278

@@ -1284,7 +1295,8 @@ changes:
12841295

12851296
Type: Runtime
12861297

1287-
The [`util.isSymbol()`][] API is deprecated.
1298+
The [`util.isSymbol()`][] API is deprecated. Please use
1299+
`typeof arg === 'symbol'` instead.
12881300

12891301
### DEP0058: `util.isUndefined()`
12901302

@@ -1307,7 +1319,8 @@ changes:
13071319

13081320
Type: Runtime
13091321

1310-
The [`util.isUndefined()`][] API is deprecated.
1322+
The [`util.isUndefined()`][] API is deprecated. Please use
1323+
`arg === undefined` instead.
13111324

13121325
### DEP0059: `util.log()`
13131326

@@ -1326,7 +1339,17 @@ changes:
13261339

13271340
Type: Runtime
13281341

1329-
The [`util.log()`][] API is deprecated.
1342+
The [`util.log()`][] API has been deprecated because it's an unmaintained
1343+
legacy API that was exposed to user land by accident. Instead,
1344+
consider the following alternatives based on your specific needs:
1345+
1346+
* **Third-Party Logging Libraries**
1347+
1348+
* **Use `console.log(new Date().toLocaleString(), message)`**
1349+
1350+
By adopting one of these alternatives, you can transition away from `util.log()`
1351+
and choose a logging strategy that aligns with the specific
1352+
requirements and complexity of your application.
13301353

13311354
### DEP0060: `util._extend()`
13321355

@@ -1345,7 +1368,9 @@ changes:
13451368

13461369
Type: Runtime
13471370

1348-
The [`util._extend()`][] API is deprecated.
1371+
The [`util._extend()`][] API is deprecated because it's an unmaintained
1372+
legacy API that was exposed to user land by accident.
1373+
Please use `target = Object.assign(target, source)` instead.
13491374

13501375
### DEP0061: `fs.SyncWriteStream`
13511376

lib/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ module.exports = {
431431
'Please use `arg !== null && typeof arg === "object"` instead.',
432432
'DEP0053'),
433433
isDate: deprecate(types.isDate,
434-
'The `util.isDate API is deprecated. Please use `arg instanceof Error` instead.',
434+
'The `util.isDate` API is deprecated. Please use `arg instanceof Date` instead.',
435435
'DEP0047'),
436436
isError: deprecate(isError,
437437
'The `util.isError` API is deprecated. ' +

0 commit comments

Comments
 (0)