-
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
Add indent option to util.inspect? #14638
Comments
I'd like to get feedback from some of the heaviest users of I'm personally +1. |
One question is how the interaction of |
🤔 > console.log(util.inspect(o, {breakLength:4}))
{ a: 1,
b: 2,
c: 3,
d: 4,
e:
[ 1,
2,
3,
4,
{ f: 6,
g: [Array] } ] } If anyone can find an example case IMHO it should also go into the current tests. [refack: edited claim for spec compliance] |
Looks like I actually misinterpreted the |
ping @domenic, you had reservations to share? |
I don't see the motivation for this. Despite claims above, this has nothing to do with spec compliance. This is just someone's subjective formatting preferences. The name "indent" is especially bad; the lines are already indented. This is actually about inserting newlines (again, at a place that one contributor thinks looks nicer). I don't think util.format should be a general-purpose formatting with additional options for everyone's aesthetic preferences. I think that's better left to libraries. The existing formatter is a great balance of readability and conciseness. |
@domenic I see your point. And I don't claim that this will make anything "up to spec" but the current implementation of the P.S. we're talking about |
agree that 'indent' is not the best name for the option if we choose to move forward with this. Maybe something like |
So this discussion has been pretty quiet for several days, how do I know if its worth working on or not? |
I'd interpret the current responses as being not enough to warrant an implementation. Let's give it a bit more time and otherwise close it. |
As others have articulated,
So for these reasons, I'm leaning towards closing this ticket as well. |
Can anyone see a path forward? We have a opinionated implementation (
BTW: AFAICT Lines 189 to 191 in ab2b331
breakLength (https://github.com/nodejs/node/search?utf8=%E2%9C%93&q=breakLength&type=)
|
I'm closing this issue as there seems to be very limited support for this feature from Collaborators (myself included), and as the discussion has died down. |
This feature would be a huge improvement to the entire Node.js ecosystem. You've got to be able to view your objects from the terminal out of box without third party modules for debugging, this affects everyone. Non pretty inspect is just too unreadable. If anything is greenlighted in that direction, I can try to implement. |
It would be a lot easier to implement this by now than three years ago. We internally use nesting levels that could just be repeated by the named indentation (or we allow numbers). |
It was mentioned in comment on PR, that it might useful to have 'real indenting' for
util.inspect
via a new option passed in. This is to make it function more like JSON.stringify with passing in a space specifier. Is this something that people would like to see? Would it be useful?Refs: #14545
The text was updated successfully, but these errors were encountered: