Skip to content

Commit

Permalink
Add ansi256 and bgAnsi256 to TypeScript declarations (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrottimark authored and sindresorhus committed Oct 8, 2019
1 parent eef8c8c commit fb8e85a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
10 changes: 10 additions & 0 deletions index.d.ts
Expand Up @@ -213,6 +213,11 @@ declare namespace chalk {
*/
hwb(hue: number, whiteness: number, blackness: number): Chalk;

/**
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
*/
ansi256(index: number): Chalk;

/**
Use HEX value to set background color.
Expand Down Expand Up @@ -261,6 +266,11 @@ declare namespace chalk {
*/
bgHwb(hue: number, whiteness: number, blackness: number): Chalk;

/**
Use a [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set background color.
*/
bgAnsi256(index: number): Chalk;

/**
Modifier: Resets the current color chain.
*/
Expand Down
2 changes: 2 additions & 0 deletions index.test-d.ts
Expand Up @@ -49,12 +49,14 @@ expectType<colorReturn>(chalk.rgb(0, 0, 0));
expectType<colorReturn>(chalk.hsl(0, 0, 0));
expectType<colorReturn>(chalk.hsv(0, 0, 0));
expectType<colorReturn>(chalk.hwb(0, 0, 0));
expectType<colorReturn>(chalk.ansi256(0));
expectType<colorReturn>(chalk.bgHex('#DEADED'));
expectType<colorReturn>(chalk.bgKeyword('orange'));
expectType<colorReturn>(chalk.bgRgb(0, 0, 0));
expectType<colorReturn>(chalk.bgHsl(0, 0, 0));
expectType<colorReturn>(chalk.bgHsv(0, 0, 0));
expectType<colorReturn>(chalk.bgHwb(0, 0, 0));
expectType<colorReturn>(chalk.bgAnsi256(0));

// -- Modifiers --
expectType<string>(chalk.reset('foo'));
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Expand Up @@ -260,9 +260,9 @@ The following color models can be used:
- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
- `ansi16`
- `ansi256`
- [`ansi256`](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) - Example: `chalk.bgAnsi256(194)('Honeydew, more or less')`


## Windows
Expand Down

0 comments on commit fb8e85a

Please sign in to comment.