Skip to content

Request to undeprecate util.is* functions #43715

@WillAvudim

Description

@WillAvudim

What is the problem this feature will solve?

I'd like to request to undeprecate all util.is* functions currently marked for deprecation, and keep them intact in all future versions of Node.js.

What is the feature you are proposing to solve the problem?

Reasons:

  1. util.is* functions (util.isObject, util.isNumber, util.isRegExp) are immensely useful and used throughout the codebase of pretty much every Node.js app.

  2. They are succinct and help to avoid unnecessary cognitive load, while the suggested alternatives are verbose and difficult to remember, and write correctly every single time.

Take for example util.isObject and compare the function isObject:

if (isObject(functionThatReturnsObject(param1, param2)) { ... }

VS what its documentation suggests I'd have to write instead:

if (functionThatReturnsObject(param1, param2) !== null && typeof functionThatReturnsObject(param1, param2) === 'object') { ... }

Do you really think that the second fragment is more obvious to any software engineer out there?

  1. The alternative implementation, e.g. lodash, is less efficient since it has to handle many corner cases not applicable to Node.js. And lodash detects Node.js and uses util.is* functions underneath for efficiency, e.g. https://github.com/lodash/lodash/blob/ddfd9b11a0126db2302cb70ec9973b66baec0975/lodash.js#L452

  2. They have great typescript annotations already written and maintained.

What alternatives have you considered?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions