Deprecated current style names in favor of using Name suffix

This commit is contained in:
LitoMore 2022-10-11 22:40:12 +08:00
parent 553c46871a
commit 8011f5f507
No known key found for this signature in database
GPG key ID: B8653F9344667340
4 changed files with 107 additions and 23 deletions

View file

@ -210,19 +210,19 @@ Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=
`chalkStderr` contains a separate instance configured with color support detected for `stderr` stream instead of `stdout`. Override rules from `supportsColor` apply to this too. `supportsColorStderr` is exposed for convenience.
### modifiers, foregroundColors, backgroundColors, and colors
### modifierNames, foregroundColorNames, backgroundColorNames, and colorNames
All supported style strings are exposed as an array of strings for convenience. `colors` is the combination of `foregroundColors` and `backgroundColors`.
All supported style strings are exposed as an array of strings for convenience. `colorNames` is the combination of `foregroundColorNames` and `backgroundColorNames`.
This can be useful if you wrap Chalk and need to validate input:
```js
import {modifiers, foregroundColors} from 'chalk';
import {modifierNames, foregroundColorNames} from 'chalk';
console.log(modifiers.includes('bold'));
console.log(modifierNames.includes('bold'));
//=> true
console.log(foregroundColors.includes('pink'));
console.log(foregroundColorNames.includes('pink'));
//=> false
```