Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9258604

Browse filesBrowse files
BridgeARtargos
authored andcommitted
doc: fix outdated util inspect documentation and layout example
The documentation and layout example was not up to date with the latest changes. Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de> PR-URL: #37079 Fixes: #37054 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent ec5b06e commit 9258604
Copy full SHA for 9258604

File tree

Expand file treeCollapse file tree

1 file changed

+10
-14
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-14
lines changed
Open diff view settings
Collapse file

‎doc/api/util.md‎

Copy file name to clipboardExpand all lines: doc/api/util.md
+10-14Lines changed: 10 additions & 14 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,11 @@ changes:
576576
(in combination with `compact` set to `true` or any number >= `1`).
577577
**Default:** `80`.
578578
* `compact` {boolean|integer} Setting this to `false` causes each object key
579-
to be displayed on a new line. It will also add new lines to text that is
579+
to be displayed on a new line. It will break on new lines in text that is
580580
longer than `breakLength`. If set to a number, the most `n` inner elements
581581
are united on a single line as long as all properties fit into
582-
`breakLength`. Short array elements are also grouped together. No
583-
text will be reduced below 16 characters, no matter the `breakLength` size.
584-
For more information, see the example below. **Default:** `3`.
582+
`breakLength`. Short array elements are also grouped together. For more
583+
information, see the example below. **Default:** `3`.
585584
* `sorted` {boolean|Function} If set to `true` or a function, all properties
586585
of an object, and `Set` and `Map` entries are sorted in the resulting
587586
string. If set to `true` the [default sort][] is used. If set to a function,
@@ -649,8 +648,8 @@ const util = require('util');
649648

650649
const o = {
651650
a: [1, 2, [[
652-
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do ' +
653-
'eiusmod tempor incididunt ut labore et dolore magna aliqua.',
651+
'Lorem ipsum dolor sit amet,\nconsectetur adipiscing elit, sed do ' +
652+
'eiusmod \ntempor incididunt ut labore et dolore magna aliqua.',
654653
'test',
655654
'foo']], 4],
656655
b: new Map([['za', 1], ['zb', 'test']])
@@ -660,13 +659,13 @@ console.log(util.inspect(o, { compact: true, depth: 5, breakLength: 80 }));
660659
// { a:
661660
// [ 1,
662661
// 2,
663-
// [ [ 'Lorem ipsum dolor sit amet, consectetur [...]', // A long line
662+
// [ [ 'Lorem ipsum dolor sit amet,\nconsectetur [...]', // A long line
664663
// 'test',
665664
// 'foo' ] ],
666665
// 4 ],
667666
// b: Map(2) { 'za' => 1, 'zb' => 'test' } }
668667

669-
// Setting `compact` to false changes the output to be more reader friendly.
668+
// Setting `compact` to false or an integer creates more reader friendly output.
670669
console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 }));
671670

672671
// {
@@ -675,10 +674,9 @@ console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 }));
675674
// 2,
676675
// [
677676
// [
678-
// 'Lorem ipsum dolor sit amet, consectetur ' +
679-
// 'adipiscing elit, sed do eiusmod tempor ' +
680-
// 'incididunt ut labore et dolore magna ' +
681-
// 'aliqua.,
677+
// 'Lorem ipsum dolor sit amet,\n' +
678+
// 'consectetur adipiscing elit, sed do eiusmod \n' +
679+
// 'tempor incididunt ut labore et dolore magna aliqua.',
682680
// 'test',
683681
// 'foo'
684682
// ]
@@ -693,8 +691,6 @@ console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 }));
693691

694692
// Setting `breakLength` to e.g. 150 will print the "Lorem ipsum" text in a
695693
// single line.
696-
// Reducing the `breakLength` will split the "Lorem ipsum" text in smaller
697-
// chunks.
698694
```
699695

700696
The `showHidden` option allows [`WeakMap`][] and [`WeakSet`][] entries to be

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.