Export styles from ansi-styles (#567)

This commit is contained in:
LitoMore 2022-10-12 17:35:02 +08:00 committed by GitHub
parent 92c55db46f
commit 6e0df055f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 219 additions and 115 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
```