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

util.inspect() should take an "options" object #4085

Closed
TooTallNate opened this issue Oct 6, 2012 · 3 comments
Closed

util.inspect() should take an "options" object #4085

TooTallNate opened this issue Oct 6, 2012 · 3 comments
Assignees
Labels

Comments

@TooTallNate
Copy link

It takes 4 arguments, pending 5 in #2717. It should take 2, the object itself and optionally an "options" argument for our sanity:

  • showHidden - default false - If true, then print the object's non-enumerable properties as well
  • depth - default 2 - The number of times to recurse while formatting the object. If null is passed then it will recurse indefinitely.
  • colors - default false - If true then the output will be styled with ANSI escape codes.

We can probably do this in a backwards compatible way.

@isaacs
Copy link

isaacs commented Oct 7, 2012

+1, but yes, it must sniff for non-object args and support the old api as well.

@Mithgol
Copy link

Mithgol commented Oct 9, 2012

I guess util.inspect() is mostly used in REPL, and it's not easy to type long names of options.

That's why I suggest the following name changes (shortening):

  • showHiddenunhide
  • colorscolor

@ghost ghost assigned TooTallNate Oct 10, 2012
@TooTallNate
Copy link
Author

Can someone review 881f9c4?

@Mithgol I don't so much mind the option names. If you're using inspect in the REPL a lot I suggest you create a simple helper function real quick:

function i (obj) {
  return util.inspect(obj, { showHidden: true, colors: true, depth: Infinity });
}

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

No branches or pull requests

3 participants