Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

customInspect method should take options argument. #5822

Closed
NodeGuy opened this issue Jul 9, 2013 · 0 comments
Closed

customInspect method should take options argument. #5822

NodeGuy opened this issue Jul 9, 2013 · 0 comments

Comments

@NodeGuy
Copy link

NodeGuy commented Jul 9, 2013

util.inspect calls custom inspect methods on objects. This is great. It doesn't pass its options argument to the custom method, which is not great.

As a result, e.g., the options showHidden and colors aren't applied recursively to objects with custom inspect methods.

Current behavior:

> var parent = {child: {'visible': "I am visible."}};
> Object.defineProperty(parent.child, 'hidden', {value: "I am hidden."});
> parent.inspect = function (options) { return "Here's my child: " + util.inspect(this.child, options); };
> util.inspect(parent, {showHidden: true});
'Here\'s my child: { visible: \'I am visible.\' }'

Desired behavior:

> util.inspect(parent, {showHidden: true});
'Here\'s my child: { visible: \'I am visible.\', [hidden]: \'I am hidden.\' }'
tjfontaine added a commit to tjfontaine/node that referenced this issue Aug 22, 2013
Objects with custom inpsect functions should get the options that were
passed to `util.inspect()`

fixes nodejs#5822
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant