Skip to content

Commit

Permalink
util: move util.isDate to eol
Browse files Browse the repository at this point in the history
PR-URL: nodejs#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]>
  • Loading branch information
marco-ippolito authored and nodejs-github-bot committed May 6, 2024
1 parent bd559e3 commit b5cae4f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 41 deletions.
7 changes: 5 additions & 2 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,9 @@ The `util.isBuffer()` API has been removed. Please use

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/52744
description: End-of-Life deprecation.
- version: v22.0.0
pr-url: https://github.com/nodejs/node/pull/50488
description: Runtime deprecation.
Expand All @@ -1065,9 +1068,9 @@ changes:
description: Documentation-only deprecation.
-->

Type: Runtime
Type: End-of-Life

The [`util.isDate()`][] API is deprecated. Please use
The `util.isDate()` API has been removed. Please use
`arg instanceof Date` instead.

### DEP0048: `util.isError()`
Expand Down
26 changes: 0 additions & 26 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -2950,31 +2950,6 @@ util.isArray({});
// Returns: false
```
### `util.isDate(object)`
<!-- YAML
added: v0.6.0
deprecated: v4.0.0
-->
> Stability: 0 - Deprecated: Use [`util.types.isDate()`][] instead.
* `object` {any}
* Returns: {boolean}
Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`.
```js
const util = require('node:util');

util.isDate(new Date());
// Returns: true
util.isDate(Date());
// false (without 'new' returns a String)
util.isDate({});
// Returns: false
```
### `util.isError(object)`
<!-- YAML
Expand Down Expand Up @@ -3152,7 +3127,6 @@ util.log('Timestamped message.');
[`util.promisify()`]: #utilpromisifyoriginal
[`util.types.isAnyArrayBuffer()`]: #utiltypesisanyarraybuffervalue
[`util.types.isArrayBuffer()`]: #utiltypesisarraybuffervalue
[`util.types.isDate()`]: #utiltypesisdatevalue
[`util.types.isNativeError()`]: #utiltypesisnativeerrorvalue
[`util.types.isSharedArrayBuffer()`]: #utiltypesissharedarraybuffervalue
[async function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function
Expand Down
3 changes: 0 additions & 3 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,6 @@ module.exports = {
}
return internalDeepEqual(a, b);
},
isDate: deprecate(types.isDate,
'The `util.isDate` API is deprecated. Please use `arg instanceof Date` instead.',
'DEP0047'),
isError: deprecate(isError,
'The `util.isError` API is deprecated. ' +
'Please use `ObjectPrototypeToString(e) === "[object Error]" ' +
Expand Down
10 changes: 0 additions & 10 deletions test/parallel/test-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,6 @@ assert.strictEqual(util.isArray(/regexp/), false);
assert.strictEqual(util.isArray(new Error()), false);
assert.strictEqual(util.isArray({ __proto__: Array.prototype }), false);

// isDate
assert.strictEqual(util.isDate(new Date()), true);
assert.strictEqual(util.isDate(new Date(0), 'foo'), true);
assert.strictEqual(util.isDate(new (context('Date'))()), true);
assert.strictEqual(util.isDate(Date()), false);
assert.strictEqual(util.isDate({}), false);
assert.strictEqual(util.isDate([]), false);
assert.strictEqual(util.isDate(new Error()), false);
assert.strictEqual(util.isDate({ __proto__: Date.prototype }), false);

// isError
assert.strictEqual(util.isError(new Error()), true);
assert.strictEqual(util.isError(new TypeError()), true);
Expand Down

0 comments on commit b5cae4f

Please sign in to comment.