Skip to content

Commit

Permalink
doc: update util colors
Browse files Browse the repository at this point in the history
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 <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
BridgeAR committed Apr 15, 2019
1 parent 90e958a commit ffd2df0
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -638,23 +638,25 @@ via the `util.inspect.styles` and `util.inspect.colors` properties.

The default styles and associated colors are:

* `number` - `yellow`
* `bigint` - `yellow`
* `boolean` - `yellow`
* `string` - `green`
* `date` - `magenta`
* `module` - `underline`
* `regexp` - `red`
* `name` - (no styling)
* `null` - `bold`
* `number` - `yellow`
* `regexp` - `red`
* `special` - `cyan` (e.g., `Proxies`)
* `string` - `green`
* `symbol` - `green`
* `undefined` - `grey`
* `special` - `cyan` (only applied to functions at this time)
* `name` - (no styling)

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

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

### Custom inspection functions on Objects

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

0 comments on commit ffd2df0

Please sign in to comment.