From fb8e85ab875eb95b55448fd615daacf8c325cf44 Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Tue, 8 Oct 2019 05:02:34 -0400 Subject: [PATCH] Add `ansi256` and `bgAnsi256` to TypeScript declarations (#368) --- index.d.ts | 10 ++++++++++ index.test-d.ts | 2 ++ readme.md | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 52dd5ae..c50c17e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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. @@ -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. */ diff --git a/index.test-d.ts b/index.test-d.ts index bc3d17a..dd3ba99 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -49,12 +49,14 @@ expectType(chalk.rgb(0, 0, 0)); expectType(chalk.hsl(0, 0, 0)); expectType(chalk.hsv(0, 0, 0)); expectType(chalk.hwb(0, 0, 0)); +expectType(chalk.ansi256(0)); expectType(chalk.bgHex('#DEADED')); expectType(chalk.bgKeyword('orange')); expectType(chalk.bgRgb(0, 0, 0)); expectType(chalk.bgHsl(0, 0, 0)); expectType(chalk.bgHsv(0, 0, 0)); expectType(chalk.bgHwb(0, 0, 0)); +expectType(chalk.bgAnsi256(0)); // -- Modifiers -- expectType(chalk.reset('foo')); diff --git a/readme.md b/readme.md index 6e52c05..7322f2b 100644 --- a/readme.md +++ b/readme.md @@ -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