-
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: add tagOnly option to util.inspect #17140
Conversation
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.
Documentation correction needed, but other than that, looks OK to me. No opinion as to whether this should be exposed as proposed here or instead added to internal/util.js
somehow. I think I'm in favor of exposing it, but I don't have a strong opinion.
doc/api/util.md
Outdated
@@ -327,6 +327,8 @@ changes: | |||
* `options` {Object} | |||
* `showHidden` {boolean} If `true`, the `object`'s non-enumerable symbols and | |||
properties will be included in the formatted result. Defaults to `false`. | |||
* `showHidden` {boolean} If `true`, the `object`'s keys/values will be |
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.
This should say showNone
rather than showHidden
I think?
i was originally going to throw it in internal but i couldn't think of a good way to split this up from util.inspect that didn't kill perf or require large amounts of duplication. I think its probably fine to just have the option. |
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.
Code looks OK to me. I don't really like the name showNone
though. Perhaps something like tagsOnly
or similar. Sorry for the bikeshed.
@cjihrig no problem! i don't really like |
i like |
doc/api/util.md
Outdated
@@ -327,6 +327,8 @@ changes: | |||
* `options` {Object} | |||
* `showHidden` {boolean} If `true`, the `object`'s non-enumerable symbols and | |||
properties will be included in the formatted result. Defaults to `false`. | |||
* `tagOnly` {boolean} If `true`, only the tag of `object` will be shown, |
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.
there may need to be additional detail about what is meant by "tag" here.
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 was thinking the same thing, but i wasn't sure what to write, so i just hoped the example below would be enough
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.
If `true`, only the object type (tag) will be shown, ignoring all keys and values. Printing is like the same object being empty. Defaults to `false`.
Something like that?
@devsnek what about calling it |
I can't think of a good way to not expose it |
@devsnek you are right, I meant not documenting it. There is another option not documented at the moment, so it would work similar. |
@BridgeAR i have no qualms with that, shall i remove the docs? |
7e19899
to
8be2c63
Compare
i'm just gonna close this since something moderately similar can be achieved with -1 depth and the pr appears to be dead |
@devsnek I like the thought about the Thanks a lot for the PR anyway and I am sorry that I did not look into it earlier again! |
Returns the inspected value without inspecting the keys/values of the
object.
I am requesting to add this feature mostly so that it can be used with console.table, but I'm sure people will use it for other things too.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
util