-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
util: deprecate most of util.is*() #6235
Conversation
exports.isNullOrUndefined = isNullOrUndefined; | ||
exports.isNullOrUndefined = internalUtil.deprecate(isNullOrUndefined, | ||
'util.isNullOrUndefined() is deprecated. Use the following instead:\n' + | ||
'arg === null || arg === undefined'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or arg == null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on == null
. Last I looked at the optimizing compiler nullOrUndefined is special cased.
LGTM |
Still not convinced this is actually 100% the right thing to do fwiw |
@Fishrock123 You mean in general or specifically the c++ |
@mscdex both, any of the above |
7da4fd4
to
c7066fb
Compare
exports.isFunction = isFunction; | ||
exports.isFunction = internalUtil.deprecate(isFunction, | ||
'util.isFunction() is deprecated. ' + | ||
'Use typeof arg === \'function\' instead.'); | ||
|
||
function isPrimitive(arg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would separate out the change to isPrimitive
to a separate commit or PR.
I still say +1 on this. With exception to |
@jasnell Problem is that presents no consistency at all.. it's hard to justify either way.. like what will we add for future things that v8 may have checks for? I'm less and less convinced we should even expose the v8 checks. There must be reasonable ways to get this in JS otherwise JS would present checks for it for browsers... cc @ljharb and @bmeck ... What is the recommended way of type checking these things in JS? On our end these are most notably used for how we render in |
the Proxy discussion is a good example of this. In the normal case, there's no reason for most users to need to check to see if an object is a Proxy but util.inspect() provides a valid use case for why we'd want to know if it is or not. However, I don't feel strongly about it. If you don't think there's value is having any of them, deprecate them all and don't add any new ones. |
I'm still very much in favor of keeping the things that can't be done with 100% certainty in JavaScript without deferring to a native addon that does this same thing. Even if this is an inconsistent API, it will still be far from the worst thing in core. |
Also, browsers don't have to account for things that cross the |
@Fishrock123 https://npmjs.com/~ljharb - most everything starting with "is". If |
c133999
to
83c7a88
Compare
Ping @Fishrock123 ... just checking in on this... what do you want to do with this? I'd recommend closing if it's not yet clear if this should happen. |
no clue I guess the APIs will just sit in limbo forever |
Rename the tests appropriately alongside mentioning the subsystem Also, make a few basic changes to make sure the tests conform to the standard test structure - Rename test-regress-nodejsGH-9819 to test-crypto-tostring-segfault - Rename test-regress-nodejsGH-5051 to test-http-addrequest-localaddress - Rename test-regress-nodejsGH-5727 to test-net-listen-invalid-port - Rename test-regress-nodejsGH-5927 to test-tty-stdin-pipe - Rename test-regress-nodejsGH-6235 to test-v8-global-setter Refs: nodejs#19105 Refs: https://github.com/nodejs/node/blob/master/doc/guides/writing-tests.md#test-structure
Rename the tests appropriately alongside mentioning the subsystem. Also, make a few basic changes to make sure the tests conform to the standard test structure. - Rename test-regress-GH-9819 to test-crypto-tostring-segfault - Rename test-regress-GH-5051 to test-http-addrequest-localaddress - Rename test-regress-GH-5727 to test-net-listen-invalid-port - Rename test-regress-GH-5927 to test-tty-stdin-pipe - Rename test-regress-GH-6235 to test-v8-global-setter PR-URL: #19275 Refs: #19105 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Rename the tests appropriately alongside mentioning the subsystem. Also, make a few basic changes to make sure the tests conform to the standard test structure. - Rename test-regress-GH-9819 to test-crypto-tostring-segfault - Rename test-regress-GH-5051 to test-http-addrequest-localaddress - Rename test-regress-GH-5727 to test-net-listen-invalid-port - Rename test-regress-GH-5927 to test-tty-stdin-pipe - Rename test-regress-GH-6235 to test-v8-global-setter PR-URL: #19275 Refs: #19105 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Rename the tests appropriately alongside mentioning the subsystem. Also, make a few basic changes to make sure the tests conform to the standard test structure. - Rename test-regress-GH-9819 to test-crypto-tostring-segfault - Rename test-regress-GH-5051 to test-http-addrequest-localaddress - Rename test-regress-GH-5727 to test-net-listen-invalid-port - Rename test-regress-GH-5927 to test-tty-stdin-pipe - Rename test-regress-GH-6235 to test-v8-global-setter PR-URL: #19275 Refs: #19105 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Rename the tests appropriately alongside mentioning the subsystem. Also, make a few basic changes to make sure the tests conform to the standard test structure. - Rename test-regress-nodejsGH-9819 to test-crypto-tostring-segfault - Rename test-regress-nodejsGH-5051 to test-http-addrequest-localaddress - Rename test-regress-nodejsGH-5727 to test-net-listen-invalid-port - Rename test-regress-nodejsGH-5927 to test-tty-stdin-pipe - Rename test-regress-nodejsGH-6235 to test-v8-global-setter PR-URL: nodejs#19275 Refs: nodejs#19105 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Checklist
Affected core subsystem(s)
util
Description of change
Supersedes #1301
This deprecates most of util.is except some stuff for which v8 has internal functions for and primitives.
To be quite honest, I don't really know what to do here, if this is remotely right, etc.
cc @nodejs/ctc I guess
note: the tests currently log a ton of warnings but I can't be bothered to fix them until we decide on what is the best path forward