-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Description
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:
-
util.is*
functions (util.isObject
,util.isNumber
,util.isRegExp
) are immensely useful and used throughout the codebase of pretty much every Node.js app. -
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?
-
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 -
They have great typescript annotations already written and maintained.
What alternatives have you considered?
No response