GeezerVison is showing github.com — doc: update migration recomendations for `util.is**()` deprecations · nodejs/node@3276bfa
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: doc/api/deprecations.md +6-6Lines changed: 6 additions & 6 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1079,6 +1079,10 @@ Type: End-of-Life |
1079 | 1079 | The `util.isDate()` API has been removed. Please use |
1080 | 1080 | `arg instanceof Date` instead. |
1081 | 1081 |
|
| 1082 | +Also for stronger approaches, consider using: |
| 1083 | +`Date.prototype.toString.call(arg) === '[object Date]' && !isNaN(arg)`. |
| 1084 | +This can also be used in a `try/catch` block to handle invalid date objects. |
| 1085 | + |
1082 | 1086 | ### DEP0048: `util.isError()` |
1083 | 1087 |
|
1084 | 1088 | <!-- YAML |
@@ -1103,9 +1107,7 @@ changes: |
1103 | 1107 |
|
1104 | 1108 | Type: End-of-Life |
1105 | 1109 |
|
1106 | | -The `util.isError()` API has been removed. Please use |
1107 | | -`Object.prototype.toString(arg) === '[object Error]' || arg instanceof Error` |
1108 | | -instead. |
| 1110 | +The `util.isError()` API has been removed. Please use `Error.isError(arg)`. |
1109 | 1111 |
|
1110 | 1112 | ### DEP0049: `util.isFunction()` |
1111 | 1113 |
|
@@ -1266,9 +1268,7 @@ changes: |
1266 | 1268 |
|
1267 | 1269 | Type: End-of-Life |
1268 | 1270 |
|
1269 | | -The `util.isPrimitive()` API has been removed. Please use |
1270 | | -`arg === null || (typeof arg !=='object' && typeof arg !== 'function')` |
1271 | | -instead. |
| 1271 | +The `util.isPrimitive()` API has been removed. Please use `Object(arg) !== arg` instead. |
1272 | 1272 |
|
1273 | 1273 | ### DEP0055: `util.isRegExp()` |
1274 | 1274 |
|
|