@@ -327,6 +327,9 @@ stream.write('With ES6');
327327<!-- YAML
328328added: v0.3.0
329329changes:
330+ - version: REPLACEME
331+ pr-url: https://github.com/nodejs/node/pull/17907
332+ description: The `depth` default changed to Infinity.
330333 - version: REPLACEME
331334 pr-url: https://github.com/nodejs/node/pull/REPLACEME
332335 description: The `compact` option is supported now.
@@ -349,9 +352,6 @@ changes:
349352* ` options ` {Object}
350353 * ` showHidden ` {boolean} If ` true ` , the ` object ` 's non-enumerable symbols and
351354 properties will be included in the formatted result. Defaults to ` false ` .
352- * ` depth ` {number} Specifies the number of times to recurse while formatting
353- the ` object ` . This is useful for inspecting large complicated objects.
354- Defaults to ` 2 ` . To make it recurse indefinitely pass ` null ` .
355355 * ` colors ` {boolean} If ` true ` , the output will be styled with ANSI color
356356 codes. Defaults to ` false ` . Colors are customizable, see
357357 [ Customizing ` util.inspect ` colors] [ ] .
@@ -362,8 +362,8 @@ changes:
362362 objects. Defaults to ` false ` .
363363 * ` maxArrayLength ` {number} Specifies the maximum number of array and
364364 ` TypedArray ` elements to include when formatting. Defaults to ` 100 ` . Set to
365- ` null ` to show all array elements. Set to ` 0 ` or negative to show no array
366- elements.
365+ ` null ` or ` Infinity ` to show all array elements. Set to ` 0 ` or negative to
366+ show no array elements.
367367 * ` breakLength ` {number} The length at which an object's keys are split
368368 across multiple lines. Set to ` Infinity ` to format an object as a single
369369 line. Defaults to 60 for legacy compatibility.
@@ -374,6 +374,10 @@ changes:
374374 objects the same as arrays. Note that no text will be reduced below 16
375375 characters, no matter the ` breakLength ` size. For more information, see the
376376 example below. Defaults to ` true ` .
377+ * ` depth ` {number} Specifies the number visible nested Objects in an ` object ` .
378+ This is useful to minimize the inspection output for large complicated
379+ objects. To make it recurse indefinitely pass ` null ` or ` Infinity ` . Defaults
380+ to ` Infinity ` .
377381
378382The ` util.inspect() ` method returns a string representation of ` object ` that is
379383intended for debugging. The output of ` util.inspect ` may change at any time
@@ -398,12 +402,23 @@ util.inspect(new Bar()); // 'Bar {}'
398402util .inspect (baz); // '[foo] {}'
399403```
400404
401- The following example inspects all properties of the ` util ` object :
405+ The following example limits the inspected output of the ` paths ` property :
402406
403407``` js
404408const util = require (' util' );
405409
406- console .log (util .inspect (util, { showHidden: true , depth: null }));
410+ console .log (util .inspect (module , { depth: 0 }));
411+ // Instead of showing all entries in `paths` `[Array]` is used to limit the
412+ // output for readability:
413+
414+ // Module {
415+ // id: '<repl>',
416+ // exports: {},
417+ // parent: undefined,
418+ // filename: null,
419+ // loaded: false,
420+ // children: [],
421+ // paths: [Array] }
407422```
408423
409424Values may supply their own custom ` inspect(depth, opts) ` functions, when
@@ -423,7 +438,7 @@ const o = {
423438 ' foo' ]], 4 ],
424439 b: new Map ([[' za' , 1 ], [' zb' , ' test' ]])
425440};
426- console .log (util .inspect (o, { compact: true , depth : 5 , breakLength: 80 }));
441+ console .log (util .inspect (o, { compact: true , breakLength: 80 }));
427442
428443// This will print
429444
@@ -437,7 +452,7 @@ console.log(util.inspect(o, { compact: true, depth: 5, breakLength: 80 }));
437452// b: Map { 'za' => 1, 'zb' => 'test' } }
438453
439454// Setting `compact` to false changes the output to be more reader friendly.
440- console .log (util .inspect (o, { compact: false , depth : 5 , breakLength: 80 }));
455+ console .log (util .inspect (o, { compact: false , breakLength: 80 }));
441456
442457// {
443458// a: [
0 commit comments