GeezerVison is showing github.com — util: move util.isError to eol · nodejs/node@dc37962
File treeExpand 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 +5-4Lines changed: 5 additions & 4 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1077,6 +1077,9 @@ The `util.isDate()` API has been removed. Please use | 1077 | 1077 |
| 1078 | 1078 | <!-- YAML | 1079 | 1079 | changes: | | 1080 | + - version: REPLACEME | | 1081 | + pr-url: https://github.com/nodejs/node/pull/52744 | | 1082 | + description: End-of-Life deprecation. | 1080 | 1083 | - version: v22.0.0 | 1081 | 1084 | pr-url: https://github.com/nodejs/node/pull/50488 | 1082 | 1085 | description: Runtime deprecation. | @@ -1092,9 +1095,9 @@ changes: | 1092 | 1095 | description: Documentation-only deprecation. | 1093 | 1096 | --> | 1094 | 1097 |
| 1095 | | -Type: Runtime | | 1098 | +Type: End-of-Life | 1096 | 1099 |
| 1097 | | -The [`util.isError()`][] API is deprecated. Please use | | 1100 | +The `util.isError()` API has been removed. Please use | 1098 | 1101 | `Object.prototype.toString(arg) === '[object Error]' || arg instanceof Error` | 1099 | 1102 | instead. | 1100 | 1103 |
| @@ -3809,8 +3812,6 @@ is deprecated to better align with recommendations per [NIST SP 800-38D][]. | 3809 | 3812 | [`util.inspect()`]: util.md#utilinspectobject-options | 3810 | 3813 | [`util.inspect.custom`]: util.md#utilinspectcustom | 3811 | 3814 | [`util.isArray()`]: util.md#utilisarrayobject | 3812 | | -[`util.isError()`]: util.md#utiliserrorobject | 3813 | | -[`util.isFunction()`]: util.md#utilisfunctionobject | 3814 | 3815 | [`util.isPrimitive()`]: util.md#utilisprimitiveobject | 3815 | 3816 | [`util.log()`]: util.md#utillogstring | 3816 | 3817 | [`util.promisify`]: util.md#utilpromisifyoriginal | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/util.md -43Lines changed: 0 additions & 43 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2950,47 +2950,6 @@ util.isArray({}); | 2950 | 2950 | // Returns: false | 2951 | 2951 | ``` | 2952 | 2952 |
| 2953 | | -### `util.isError(object)` | 2954 | | -
| 2955 | | -<!-- YAML | 2956 | | -added: v0.6.0 | 2957 | | -deprecated: v4.0.0 | 2958 | | ---> | 2959 | | -
| 2960 | | -> Stability: 0 - Deprecated: Use [`util.types.isNativeError()`][] instead. | 2961 | | -
| 2962 | | -* `object` {any} | 2963 | | -* Returns: {boolean} | 2964 | | -
| 2965 | | -Returns `true` if the given `object` is an [`Error`][]. Otherwise, returns | 2966 | | -`false`. | 2967 | | -
| 2968 | | -```js | 2969 | | -const util = require('node:util'); | 2970 | | - | 2971 | | -util.isError(new Error()); | 2972 | | -// Returns: true | 2973 | | -util.isError(new TypeError()); | 2974 | | -// Returns: true | 2975 | | -util.isError({ name: 'Error', message: 'an error occurred' }); | 2976 | | -// Returns: false | 2977 | | -``` | 2978 | | -
| 2979 | | -This method relies on `Object.prototype.toString()` behavior. It is | 2980 | | -possible to obtain an incorrect result when the `object` argument manipulates | 2981 | | -`@@toStringTag`. | 2982 | | -
| 2983 | | -```js | 2984 | | -const util = require('node:util'); | 2985 | | -const obj = { name: 'Error', message: 'an error occurred' }; | 2986 | | - | 2987 | | -util.isError(obj); | 2988 | | -// Returns: false | 2989 | | -obj[Symbol.toStringTag] = 'Error'; | 2990 | | -util.isError(obj); | 2991 | | -// Returns: true | 2992 | | -``` | 2993 | | -
| 2994 | 2953 | ### `util.isFunction(object)` | 2995 | 2954 |
| 2996 | 2955 | <!-- YAML | @@ -3094,7 +3053,6 @@ util.log('Timestamped message.'); | 3094 | 3053 | [`ArrayBuffer`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | 3095 | 3054 | [`DataView`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView | 3096 | 3055 | [`Date`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date | 3097 | | -[`Error`]: errors.md#class-error | 3098 | 3056 | [`Float32Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float32Array | 3099 | 3057 | [`Float64Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Float64Array | 3100 | 3058 | [`Int16Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Int16Array | @@ -3127,7 +3085,6 @@ util.log('Timestamped message.'); | 3127 | 3085 | [`util.promisify()`]: #utilpromisifyoriginal | 3128 | 3086 | [`util.types.isAnyArrayBuffer()`]: #utiltypesisanyarraybuffervalue | 3129 | 3087 | [`util.types.isArrayBuffer()`]: #utiltypesisarraybuffervalue | 3130 | | -[`util.types.isNativeError()`]: #utiltypesisnativeerrorvalue | 3131 | 3088 | [`util.types.isSharedArrayBuffer()`]: #utiltypesissharedarraybuffervalue | 3132 | 3089 | [async function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function | 3133 | 3090 | [built-in `Error` type]: https://tc39.es/ecma262/#sec-error-objects | |
Collapse file Copy file name to clipboardExpand all lines: lib/util.js -15Lines changed: 0 additions & 15 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -39,7 +39,6 @@ const { | 39 | 39 | ObjectDefineProperty, | 40 | 40 | ObjectGetOwnPropertyDescriptors, | 41 | 41 | ObjectKeys, | 42 | | - ObjectPrototypeToString, | 43 | 42 | ObjectSetPrototypeOf, | 44 | 43 | ObjectValues, | 45 | 44 | ReflectApply, | @@ -90,15 +89,6 @@ function lazyAbortController() { | 90 | 89 |
| 91 | 90 | let internalDeepEqual; | 92 | 91 |
| 93 | | -/** | 94 | | - * @deprecated since v4.0.0 | 95 | | - * @param {any} e | 96 | | - * @returns {arg is Error} | 97 | | - */ | 98 | | -function isError(e) { | 99 | | - return ObjectPrototypeToString(e) === '[object Error]' || e instanceof Error; | 100 | | -} | 101 | | - | 102 | 92 | /** | 103 | 93 | * @deprecated since v4.0.0 | 104 | 94 | * @param {any} arg | @@ -354,11 +344,6 @@ module.exports = { | 354 | 344 | } | 355 | 345 | return internalDeepEqual(a, b); | 356 | 346 | }, | 357 | | - isError: deprecate(isError, | 358 | | - 'The `util.isError` API is deprecated. ' + | 359 | | - 'Please use `ObjectPrototypeToString(e) === "[object Error]" ' + | 360 | | - '|| e instanceof Error` instead.', | 361 | | - 'DEP0048'), | 362 | 347 | isFunction: deprecate(isFunction, | 363 | 348 | 'The `util.isFunction` API is deprecated. Please use `typeof arg === "function"` instead.', | 364 | 349 | 'DEP0049'), | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-util.js -14Lines changed: 0 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -40,18 +40,6 @@ assert.strictEqual(util.isArray(/regexp/), false); | 40 | 40 | assert.strictEqual(util.isArray(new Error()), false); | 41 | 41 | assert.strictEqual(util.isArray({ __proto__: Array.prototype }), false); | 42 | 42 |
| 43 | | -// isError | 44 | | -assert.strictEqual(util.isError(new Error()), true); | 45 | | -assert.strictEqual(util.isError(new TypeError()), true); | 46 | | -assert.strictEqual(util.isError(new SyntaxError()), true); | 47 | | -assert.strictEqual(util.isError(new (context('Error'))()), true); | 48 | | -assert.strictEqual(util.isError(new (context('TypeError'))()), true); | 49 | | -assert.strictEqual(util.isError(new (context('SyntaxError'))()), true); | 50 | | -assert.strictEqual(util.isError({}), false); | 51 | | -assert.strictEqual(util.isError({ name: 'Error', message: '' }), false); | 52 | | -assert.strictEqual(util.isError([]), false); | 53 | | -assert.strictEqual(util.isError({ __proto__: Error.prototype }), true); | 54 | | - | 55 | 43 | // isPrimitive | 56 | 44 | assert.strictEqual(util.isPrimitive({}), false); | 57 | 45 | assert.strictEqual(util.isPrimitive(new Error()), false); | @@ -62,8 +50,6 @@ assert.strictEqual(util.isPrimitive(function() {}), false); | 62 | 50 | assert.strictEqual(util.isPrimitive(new Number(1)), false); | 63 | 51 | assert.strictEqual(util.isPrimitive(new String('bla')), false); | 64 | 52 | assert.strictEqual(util.isPrimitive(new Boolean(true)), false); | 65 | | -assert.strictEqual(util.isPrimitive(1), true); | 66 | | -assert.strictEqual(util.isPrimitive('bla'), true); | 67 | 53 | assert.strictEqual(util.isPrimitive(true), true); | 68 | 54 | assert.strictEqual(util.isPrimitive(undefined), true); | 69 | 55 | assert.strictEqual(util.isPrimitive(null), true); | |
|