Node: Allow to omit properties from inspection using util.inspect

Created on 21 Sep 2019  Â·  4Comments  Â·  Source: nodejs/node

I am looking for a feature like so:

util.inspect({foo:'bar', won:'ton'}, {omit: ['won']})`

there are certain properties I don't want to see, that are enumerable tho.

util wontfix

Most helpful comment

-1 Using a custom inspect function is going to be better than trying to add support for these kinds of things, especially because I can see some people wanting to add additional support for nested specifiers and such which would just make things complicated.

All 4 comments

If you control the objects here – and changes are good, given that you are interested in specific keys – you can use a custom inspection function on the object itself to omit the irrelevant keys.

well along with omit:[] I suppose an only:[] option would be good and if the library can do it saves users some trouble I suppose.

-1 Using a custom inspect function is going to be better than trying to add support for these kinds of things, especially because I can see some people wanting to add additional support for nested specifiers and such which would just make things complicated.

It looks like there's consensus that this doesn't belong in core so I'll go ahead and close this out.

Was this page helpful?
0 / 5 - 0 ratings