Skip to content

Commit

Permalink
util: move util.isPrimitive to eol
Browse files Browse the repository at this point in the history
PR-URL: #52744
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
marco-ippolito authored and nodejs-github-bot committed May 6, 2024
1 parent 7224094 commit 1d817dc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 76 deletions.
9 changes: 5 additions & 4 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,9 @@ The `util.isObject()` 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 @@ -1255,9 +1258,9 @@ changes:
description: Documentation-only deprecation.
-->

Type: Runtime
Type: End-of-Life

The [`util.isPrimitive()`][] API is deprecated. Please use
The `util.isPrimitive()` API has been removed. Please use
`arg === null || (typeof arg !=='object' && typeof arg !== 'function')`
instead.

Expand Down Expand Up @@ -3815,8 +3818,6 @@ is deprecated to better align with recommendations per [NIST SP 800-38D][].
[`util.inspect()`]: util.md#utilinspectobject-options
[`util.inspect.custom`]: util.md#utilinspectcustom
[`util.isArray()`]: util.md#utilisarrayobject
[`util.isPrimitive()`]: util.md#utilisprimitiveobject
[`util.log()`]: util.md#utillogstring
[`util.promisify`]: util.md#utilpromisifyoriginal
[`util.toUSVString()`]: util.md#utiltousvstringstring
[`util.types`]: util.md#utiltypes
Expand Down
40 changes: 0 additions & 40 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -2950,46 +2950,6 @@ util.isArray({});
// Returns: false
```
### `util.isPrimitive(object)`
<!-- YAML
added: v0.11.5
deprecated: v4.0.0
-->
> Stability: 0 - Deprecated: Use
> `(typeof value !== 'object' && typeof value !== 'function') || value === null`
> instead.
* `object` {any}
* Returns: {boolean}
Returns `true` if the given `object` is a primitive type. Otherwise, returns
`false`.
```js
const util = require('node:util');

util.isPrimitive(5);
// Returns: true
util.isPrimitive('foo');
// Returns: true
util.isPrimitive(false);
// Returns: true
util.isPrimitive(null);
// Returns: true
util.isPrimitive(undefined);
// Returns: true
util.isPrimitive({});
// Returns: false
util.isPrimitive(() => {});
// Returns: false
util.isPrimitive(/^$/);
// Returns: false
util.isPrimitive(new Date());
// Returns: false
```
### `util.log(string)`
<!-- YAML
Expand Down
15 changes: 0 additions & 15 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,6 @@ function lazyAbortController() {

let internalDeepEqual;

/**
* @deprecated since v4.0.0
* @param {any} arg
* @returns {arg is (boolean | null | number | string | symbol | undefined)}
*/
function isPrimitive(arg) {
return arg === null ||
(typeof arg !== 'object' && typeof arg !== 'function');
}

/**
* @param {number} n
* @returns {string}
Expand Down Expand Up @@ -335,11 +325,6 @@ module.exports = {
}
return internalDeepEqual(a, b);
},
isPrimitive: deprecate(isPrimitive,
'The `util.isPrimitive` API is deprecated. ' +
'Please use `arg === null || ' +
'(typeof arg !== "object" && typeof arg !== "function")` instead.',
'DEP0054'),
log: deprecate(log,
'The `util.log API is deprecated. ' +
'Please use console.log() with a custom formatter or a third-party logger instead.',
Expand Down
17 changes: 0 additions & 17 deletions test/parallel/test-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,6 @@ assert.strictEqual(util.isArray(/regexp/), false);
assert.strictEqual(util.isArray(new Error()), false);
assert.strictEqual(util.isArray({ __proto__: Array.prototype }), false);

// isPrimitive
assert.strictEqual(util.isPrimitive({}), false);
assert.strictEqual(util.isPrimitive(new Error()), false);
assert.strictEqual(util.isPrimitive(new Date()), false);
assert.strictEqual(util.isPrimitive([]), false);
assert.strictEqual(util.isPrimitive(/regexp/), false);
assert.strictEqual(util.isPrimitive(function() {}), false);
assert.strictEqual(util.isPrimitive(new Number(1)), false);
assert.strictEqual(util.isPrimitive(new String('bla')), false);
assert.strictEqual(util.isPrimitive(new Boolean(true)), false);
assert.strictEqual(util.isPrimitive(true), true);
assert.strictEqual(util.isPrimitive(undefined), true);
assert.strictEqual(util.isPrimitive(null), true);
assert.strictEqual(util.isPrimitive(Infinity), true);
assert.strictEqual(util.isPrimitive(NaN), true);
assert.strictEqual(util.isPrimitive(Symbol('symbol')), true);

assert.strictEqual(util.toUSVString('string\ud801'), 'string\ufffd');

{
Expand Down

0 comments on commit 1d817dc

Please sign in to comment.