@@ -432,51 +432,48 @@ changes:
432
432
433
433
* ` object ` {any} Any JavaScript primitive or ` Object ` .
434
434
* ` options ` {Object}
435
- * ` showHidden ` {boolean} If ` true ` , the ` object ` 's non-enumerable symbols and
436
- properties will be included in the formatted result as well as [ ` WeakMap ` ] [ ]
437
- and [ ` WeakSet ` ] [ ] entries. ** Default:** ` false ` .
435
+ * ` showHidden ` {boolean} If ` true ` , ` object ` 's non-enumerable symbols and
436
+ properties are included in the formatted result. [ ` WeakMap ` ] [ ] and
437
+ [ ` WeakSet ` ] [ ] entries are also included . ** Default:** ` false ` .
438
438
* ` depth ` {number} Specifies the number of times to recurse while formatting
439
- the ` object ` . This is useful for inspecting large complicated objects. To
440
- make it recurse up to the maximum call stack size pass ` Infinity ` or ` null ` .
439
+ ` object ` . This is useful for inspecting large objects. To recurse up to
440
+ the maximum call stack size pass ` Infinity ` or ` null ` .
441
441
** Default:** ` 2 ` .
442
- * ` colors ` {boolean} If ` true ` , the output will be styled with ANSI color
443
- codes. Colors are customizable, see [ Customizing ` util.inspect ` colors] [ ] .
442
+ * ` colors ` {boolean} If ` true ` , the output is styled with ANSI color
443
+ codes. Colors are customizable. See [ Customizing ` util.inspect ` colors] [ ] .
444
444
** Default:** ` false ` .
445
- * ` customInspect ` {boolean} If ` false ` , then
446
- ` [util.inspect.custom](depth, opts) ` functions will not be called .
445
+ * ` customInspect ` {boolean} If ` false ` ,
446
+ ` [util.inspect.custom](depth, opts) ` functions are not invoked .
447
447
** Default:** ` true ` .
448
- * ` showProxy ` {boolean} If ` true ` , then objects and functions that are
449
- ` Proxy ` objects will be introspected to show their ` target ` and ` handler `
450
- objects. ** Default:** ` false ` .
448
+ * ` showProxy ` {boolean} If ` true ` , ` Proxy ` inspection includes
449
+ the [ ` target ` and ` handler ` ] [ ] objects. ** Default:** ` false ` .
451
450
* ` maxArrayLength ` {integer} Specifies the maximum number of ` Array ` ,
452
451
[ ` TypedArray ` ] [ ] , [ ` WeakMap ` ] [ ] and [ ` WeakSet ` ] [ ] elements to include when
453
452
formatting. Set to ` null ` or ` Infinity ` to show all elements. Set to ` 0 ` or
454
453
negative to show no elements. ** Default:** ` 100 ` .
455
454
* ` breakLength ` {integer} The length at which an object's keys are split
456
455
across multiple lines. Set to ` Infinity ` to format an object as a single
457
456
line. ** Default:** ` 60 ` for legacy compatibility.
458
- * ` compact ` {boolean} Setting this to ` false ` changes the default indentation
459
- to use a line break for each object key instead of lining up multiple
460
- properties in one line. It will also break text that is above the
461
- ` breakLength ` size into smaller and better readable chunks and indents
462
- objects the same as arrays. Note that no text will be reduced below 16
457
+ * ` compact ` {boolean} Setting this to ` false ` causes each object key to
458
+ be displayed on a new line. It will also add new lines to text that is
459
+ longer than ` breakLength ` . Note that no text will be reduced below 16
463
460
characters, no matter the ` breakLength ` size. For more information, see the
464
461
example below. ** Default:** ` true ` .
465
462
* ` sorted ` {boolean|Function} If set to ` true ` or a function, all properties
466
- of an object and Set and Map entries will be sorted in the returned string.
467
- If set to ` true ` the [ default sort] [ ] is going to be used. If set to a
468
- function, it is used as a [ compare function] [ ] .
469
- * ` getters ` {boolean|string} If set to ` true ` , getters are going to be
470
- inspected as well. If set to ` 'get' ` only getters without setter are going
471
- to be inspected. If set to ` 'set' ` only getters having a corresponding
472
- setter are going to be inspected. This might cause side effects depending on
473
- the getter function. ** Default:** ` false ` .
474
- * Returns: {string} The representation of passed object
463
+ of an object, and ` Set ` and ` Map ` entries are sorted in the resulting
464
+ string. If set to ` true ` the [ default sort] [ ] is used. If set to a function,
465
+ it is used as a [ compare function] [ ] .
466
+ * ` getters ` {boolean|string} If set to ` true ` , getters are inspected. If set
467
+ to ` 'get' ` , only getters without a corresponding setter are inspected. If
468
+ set to ` 'set' ` , only getters with a corresponding setter are inspected.
469
+ This might cause side effects depending on the getter function.
470
+ ** Default:** ` false ` .
471
+ * Returns: {string} The representation of ` object ` .
475
472
476
473
The ` util.inspect() ` method returns a string representation of ` object ` that is
477
474
intended for debugging. The output of ` util.inspect ` may change at any time
478
475
and should not be depended upon programmatically. Additional ` options ` may be
479
- passed that alter certain aspects of the formatted string .
476
+ passed that alter the result .
480
477
` util.inspect() ` will use the constructor's name and/or ` @@toStringTag ` to make
481
478
an identifiable tag for an inspected value.
482
479
@@ -504,7 +501,7 @@ const util = require('util');
504
501
console .log (util .inspect (util, { showHidden: true , depth: null }));
505
502
```
506
503
507
- The following example highlights the difference with the ` compact ` option:
504
+ The following example highlights the effect of the ` compact ` option:
508
505
509
506
``` js
510
507
const util = require (' util' );
@@ -561,13 +558,11 @@ console.log(util.inspect(o, { compact: false, depth: 5, breakLength: 80 }));
561
558
// chunks.
562
559
```
563
560
564
- Using the ` showHidden ` option allows to inspect [ ` WeakMap ` ] [ ] and [ ` WeakSet ` ] [ ]
565
- entries. If there are more entries than ` maxArrayLength ` , there is no guarantee
566
- which entries are displayed. That means retrieving the same [ ` WeakSet ` ] [ ]
567
- entries twice might actually result in a different output. Besides this any item
568
- might be collected at any point of time by the garbage collector if there is no
569
- strong reference left to that object. Therefore there is no guarantee to get a
570
- reliable output.
561
+ The ` showHidden ` option allows [ ` WeakMap ` ] [ ] and [ ` WeakSet ` ] [ ] entries to be
562
+ inspected. If there are more entries than ` maxArrayLength ` , there is no
563
+ guarantee which entries are displayed. That means retrieving the same
564
+ [ ` WeakSet ` ] [ ] entries twice may result in different output. Furthermore, entries
565
+ with no remaining strong references may be garbage collected at any time.
571
566
572
567
``` js
573
568
const { inspect } = require (' util' );
@@ -580,8 +575,8 @@ console.log(inspect(weakSet, { showHidden: true }));
580
575
// WeakSet { { a: 1 }, { b: 2 } }
581
576
```
582
577
583
- The ` sorted ` option makes sure the output is identical, no matter of the
584
- properties insertion order:
578
+ The ` sorted ` option ensures that an object's property insertion order does not
579
+ impact the result of ` util.inspect() ` .
585
580
586
581
``` js
587
582
const { inspect } = require (' util' );
@@ -608,11 +603,9 @@ assert.strict.equal(
608
603
);
609
604
```
610
605
611
- Please note that ` util.inspect() ` is a synchronous method that is mainly
612
- intended as a debugging tool. Its maximum output length is limited to
613
- approximately 128 MB and input values that result in output bigger than that
614
- will not be inspected fully. Such values can have a significant performance
615
- overhead that can block the event loop for a significant amount of time.
606
+ ` util.inspect() ` is a synchronous method intended for debugging. Its maximum
607
+ output length is approximately 128 MB. Inputs that result in longer output will
608
+ be truncated.
616
609
617
610
### Customizing ` util.inspect ` colors
618
611
@@ -2222,6 +2215,7 @@ Deprecated predecessor of `console.log`.
2222
2215
[ `assert.deepStrictEqual()` ] : assert.html#assert_assert_deepstrictequal_actual_expected_message
2223
2216
[ `console.error()` ] : console.html#console_console_error_data_args
2224
2217
[ `console.log()` ] : console.html#console_console_log_data_args
2218
+ [ `target` and `handler` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#Terminology
2225
2219
[ `util.format()` ] : #util_util_format_format_args
2226
2220
[ `util.inspect()` ] : #util_util_inspect_object_options
2227
2221
[ `util.promisify()` ] : #util_util_promisify_original
0 commit comments