Skip to content

Request to undeprecate util.is* functions #4702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
WillAvudim opened this issue Jul 6, 2022 · 2 comments
Closed

Request to undeprecate util.is* functions #4702

WillAvudim opened this issue Jul 6, 2022 · 2 comments

Comments

@WillAvudim
Copy link

WillAvudim commented Jul 6, 2022

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.

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 the 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.

@SEWeiTung
Copy link
Contributor

SEWeiTung commented Jul 7, 2022

This discussion can be moved to node.js instead of here for more notifications :)

@WillAvudim
Copy link
Author

Oh, you're right, my apologies. Filed as nodejs/node#43715. Closing this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants