Skip to content

Commit ffd2df0

Browse files
committed
doc: update util colors
This updates the customization of colors for `util.inspect`. A couple entries were missing and this also adds a reference to check for colors. PR-URL: #27052 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 90e958a commit ffd2df0

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

doc/api/util.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -638,23 +638,25 @@ via the `util.inspect.styles` and `util.inspect.colors` properties.
638638

639639
The default styles and associated colors are:
640640

641-
* `number` - `yellow`
641+
* `bigint` - `yellow`
642642
* `boolean` - `yellow`
643-
* `string` - `green`
644643
* `date` - `magenta`
645644
* `module` - `underline`
646-
* `regexp` - `red`
645+
* `name` - (no styling)
647646
* `null` - `bold`
647+
* `number` - `yellow`
648+
* `regexp` - `red`
649+
* `special` - `cyan` (e.g., `Proxies`)
650+
* `string` - `green`
651+
* `symbol` - `green`
648652
* `undefined` - `grey`
649-
* `special` - `cyan` (only applied to functions at this time)
650-
* `name` - (no styling)
651653

652654
The predefined color codes are: `white`, `grey`, `black`, `blue`, `cyan`,
653655
`green`, `magenta`, `red` and `yellow`. There are also `bold`, `italic`,
654656
`underline` and `inverse` codes.
655657

656658
Color styling uses ANSI control codes that may not be supported on all
657-
terminals.
659+
terminals. To verify color support use [`tty.hasColors()`][].
658660

659661
### Custom inspection functions on Objects
660662

@@ -2191,6 +2193,7 @@ util.log('Timestamped message.');
21912193
[`assert.deepStrictEqual()`]: assert.html#assert_assert_deepstrictequal_actual_expected_message
21922194
[`console.error()`]: console.html#console_console_error_data_args
21932195
[`target` and `handler`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#Terminology
2196+
[`tty.hasColors()`]: tty.html#tty_writestream_hascolors_count_env
21942197
[`util.format()`]: #util_util_format_format_args
21952198
[`util.inspect()`]: #util_util_inspect_object_options
21962199
[`util.promisify()`]: #util_util_promisify_original

0 commit comments

Comments
 (0)