Skip to content

util: add util.inspect compact option

I personally really dislike the formatting used in util.inspect and this should improve the situation a lot. I am also working on a feature that requires a more structural util.inspect output. In general, I do not argue about it being perfect, so if anyone has some further input, I am all ears.

commit - util: add util.inspect structured option

The current default formatting is not ideal and this improves
the situation by formatting the output more intuitiv.

1) All object keys are now indented by 2 characters instead of
   something 2 and sometimes 3 characters.
2) Each object key will now use a individual line instead of
   sharing a line potentially with multiple object keys.
3) Long strings will now be split into multiple lines in case
   they exceed the "lineBreak" option length (including the
   current indentation).
4) Opening braces are now directly behind a object property
   instead of using a new line.

commit - util: rename util.inspect argument

util.inspect can actually receive any property and the description
was wrong so far. This fixes it by renaming the argument to
value and also updating the description.

commit - util: fix custom inspect description

Using a custom inspect function on the inspected object is
deprecated. Remove the reference from the option description
to make sure the user will read about the deprecation in the
more detailed description.

CI https://ci.nodejs.org/job/node-test-pull-request/12008/

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

util

Merge request reports

Loading