ansi-styles 5.2.0 → 6.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/index.d.ts +185 -162
  2. package/index.js +81 -26
  3. package/license +1 -1
  4. package/package.json +7 -5
  5. package/readme.md +31 -20
package/index.d.ts CHANGED
@@ -1,167 +1,190 @@
1
- declare namespace ansiStyles {
2
- interface CSPair {
3
- /**
4
- The ANSI terminal control sequence for starting this style.
5
- */
6
- readonly open: string;
7
-
8
- /**
9
- The ANSI terminal control sequence for ending this style.
10
- */
11
- readonly close: string;
12
- }
13
-
14
- interface ColorBase {
15
- /**
16
- The ANSI terminal control sequence for ending this color.
17
- */
18
- readonly close: string;
19
-
20
- ansi256(code: number): string;
21
-
22
- ansi16m(red: number, green: number, blue: number): string;
23
- }
24
-
25
- interface Modifier {
26
- /**
27
- Resets the current color chain.
28
- */
29
- readonly reset: CSPair;
30
-
31
- /**
32
- Make text bold.
33
- */
34
- readonly bold: CSPair;
35
-
36
- /**
37
- Emitting only a small amount of light.
38
- */
39
- readonly dim: CSPair;
40
-
41
- /**
42
- Make text italic. (Not widely supported)
43
- */
44
- readonly italic: CSPair;
45
-
46
- /**
47
- Make text underline. (Not widely supported)
48
- */
49
- readonly underline: CSPair;
50
-
51
- /**
52
- Make text overline.
53
-
54
- Supported on VTE-based terminals, the GNOME terminal, mintty, and Git Bash.
55
- */
56
- readonly overline: CSPair;
57
-
58
- /**
59
- Inverse background and foreground colors.
60
- */
61
- readonly inverse: CSPair;
62
-
63
- /**
64
- Prints the text, but makes it invisible.
65
- */
66
- readonly hidden: CSPair;
67
-
68
- /**
69
- Puts a horizontal line through the center of the text. (Not widely supported)
70
- */
71
- readonly strikethrough: CSPair;
72
- }
73
-
74
- interface ForegroundColor {
75
- readonly black: CSPair;
76
- readonly red: CSPair;
77
- readonly green: CSPair;
78
- readonly yellow: CSPair;
79
- readonly blue: CSPair;
80
- readonly cyan: CSPair;
81
- readonly magenta: CSPair;
82
- readonly white: CSPair;
83
-
84
- /**
85
- Alias for `blackBright`.
86
- */
87
- readonly gray: CSPair;
88
-
89
- /**
90
- Alias for `blackBright`.
91
- */
92
- readonly grey: CSPair;
93
-
94
- readonly blackBright: CSPair;
95
- readonly redBright: CSPair;
96
- readonly greenBright: CSPair;
97
- readonly yellowBright: CSPair;
98
- readonly blueBright: CSPair;
99
- readonly cyanBright: CSPair;
100
- readonly magentaBright: CSPair;
101
- readonly whiteBright: CSPair;
102
- }
103
-
104
- interface BackgroundColor {
105
- readonly bgBlack: CSPair;
106
- readonly bgRed: CSPair;
107
- readonly bgGreen: CSPair;
108
- readonly bgYellow: CSPair;
109
- readonly bgBlue: CSPair;
110
- readonly bgCyan: CSPair;
111
- readonly bgMagenta: CSPair;
112
- readonly bgWhite: CSPair;
113
-
114
- /**
115
- Alias for `bgBlackBright`.
116
- */
117
- readonly bgGray: CSPair;
118
-
119
- /**
120
- Alias for `bgBlackBright`.
121
- */
122
- readonly bgGrey: CSPair;
123
-
124
- readonly bgBlackBright: CSPair;
125
- readonly bgRedBright: CSPair;
126
- readonly bgGreenBright: CSPair;
127
- readonly bgYellowBright: CSPair;
128
- readonly bgBlueBright: CSPair;
129
- readonly bgCyanBright: CSPair;
130
- readonly bgMagentaBright: CSPair;
131
- readonly bgWhiteBright: CSPair;
132
- }
133
-
134
- interface ConvertColor {
135
- /**
136
- Convert from the RGB color space to the ANSI 256 color space.
137
-
138
- @param red - (`0...255`)
139
- @param green - (`0...255`)
140
- @param blue - (`0...255`)
141
- */
142
- rgbToAnsi256(red: number, green: number, blue: number): number;
143
-
144
- /**
145
- Convert from the RGB HEX color space to the RGB color space.
146
-
147
- @param hex - A hexadecimal string containing RGB data.
148
- */
149
- hexToRgb(hex: string): [red: number, green: number, blue: number];
150
-
151
- /**
152
- Convert from the RGB HEX color space to the ANSI 256 color space.
153
-
154
- @param hex - A hexadecimal string containing RGB data.
155
- */
156
- hexToAnsi256(hex: string): number;
157
- }
1
+ export interface CSPair { // eslint-disable-line @typescript-eslint/naming-convention
2
+ /**
3
+ The ANSI terminal control sequence for starting this style.
4
+ */
5
+ readonly open: string;
6
+
7
+ /**
8
+ The ANSI terminal control sequence for ending this style.
9
+ */
10
+ readonly close: string;
11
+ }
12
+
13
+ export interface ColorBase {
14
+ /**
15
+ The ANSI terminal control sequence for ending this color.
16
+ */
17
+ readonly close: string;
18
+
19
+ ansi(code: number): string;
20
+
21
+ ansi256(code: number): string;
22
+
23
+ ansi16m(red: number, green: number, blue: number): string;
24
+ }
25
+
26
+ export interface Modifier {
27
+ /**
28
+ Resets the current color chain.
29
+ */
30
+ readonly reset: CSPair;
31
+
32
+ /**
33
+ Make text bold.
34
+ */
35
+ readonly bold: CSPair;
36
+
37
+ /**
38
+ Emitting only a small amount of light.
39
+ */
40
+ readonly dim: CSPair;
41
+
42
+ /**
43
+ Make text italic. (Not widely supported)
44
+ */
45
+ readonly italic: CSPair;
46
+
47
+ /**
48
+ Make text underline. (Not widely supported)
49
+ */
50
+ readonly underline: CSPair;
51
+
52
+ /**
53
+ Make text overline.
54
+
55
+ Supported on VTE-based terminals, the GNOME terminal, mintty, and Git Bash.
56
+ */
57
+ readonly overline: CSPair;
58
+
59
+ /**
60
+ Inverse background and foreground colors.
61
+ */
62
+ readonly inverse: CSPair;
63
+
64
+ /**
65
+ Prints the text, but makes it invisible.
66
+ */
67
+ readonly hidden: CSPair;
68
+
69
+ /**
70
+ Puts a horizontal line through the center of the text. (Not widely supported)
71
+ */
72
+ readonly strikethrough: CSPair;
73
+ }
74
+
75
+ export interface ForegroundColor {
76
+ readonly black: CSPair;
77
+ readonly red: CSPair;
78
+ readonly green: CSPair;
79
+ readonly yellow: CSPair;
80
+ readonly blue: CSPair;
81
+ readonly cyan: CSPair;
82
+ readonly magenta: CSPair;
83
+ readonly white: CSPair;
84
+
85
+ /**
86
+ Alias for `blackBright`.
87
+ */
88
+ readonly gray: CSPair;
89
+
90
+ /**
91
+ Alias for `blackBright`.
92
+ */
93
+ readonly grey: CSPair;
94
+
95
+ readonly blackBright: CSPair;
96
+ readonly redBright: CSPair;
97
+ readonly greenBright: CSPair;
98
+ readonly yellowBright: CSPair;
99
+ readonly blueBright: CSPair;
100
+ readonly cyanBright: CSPair;
101
+ readonly magentaBright: CSPair;
102
+ readonly whiteBright: CSPair;
103
+ }
104
+
105
+ export interface BackgroundColor {
106
+ readonly bgBlack: CSPair;
107
+ readonly bgRed: CSPair;
108
+ readonly bgGreen: CSPair;
109
+ readonly bgYellow: CSPair;
110
+ readonly bgBlue: CSPair;
111
+ readonly bgCyan: CSPair;
112
+ readonly bgMagenta: CSPair;
113
+ readonly bgWhite: CSPair;
114
+
115
+ /**
116
+ Alias for `bgBlackBright`.
117
+ */
118
+ readonly bgGray: CSPair;
119
+
120
+ /**
121
+ Alias for `bgBlackBright`.
122
+ */
123
+ readonly bgGrey: CSPair;
124
+
125
+ readonly bgBlackBright: CSPair;
126
+ readonly bgRedBright: CSPair;
127
+ readonly bgGreenBright: CSPair;
128
+ readonly bgYellowBright: CSPair;
129
+ readonly bgBlueBright: CSPair;
130
+ readonly bgCyanBright: CSPair;
131
+ readonly bgMagentaBright: CSPair;
132
+ readonly bgWhiteBright: CSPair;
133
+ }
134
+
135
+ export interface ConvertColor {
136
+ /**
137
+ Convert from the RGB color space to the ANSI 256 color space.
138
+
139
+ @param red - (`0...255`)
140
+ @param green - (`0...255`)
141
+ @param blue - (`0...255`)
142
+ */
143
+ rgbToAnsi256(red: number, green: number, blue: number): number;
144
+
145
+ /**
146
+ Convert from the RGB HEX color space to the RGB color space.
147
+
148
+ @param hex - A hexadecimal string containing RGB data.
149
+ */
150
+ hexToRgb(hex: string): [red: number, green: number, blue: number];
151
+
152
+ /**
153
+ Convert from the RGB HEX color space to the ANSI 256 color space.
154
+
155
+ @param hex - A hexadecimal string containing RGB data.
156
+ */
157
+ hexToAnsi256(hex: string): number;
158
+
159
+ /**
160
+ Convert from the ANSI 256 color space to the ANSI 16 color space.
161
+
162
+ @param code - A number representing the ANSI 256 color.
163
+ */
164
+ ansi256ToAnsi(code: number): number;
165
+
166
+ /**
167
+ Convert from the RGB color space to the ANSI 16 color space.
168
+
169
+ @param red - (`0...255`)
170
+ @param green - (`0...255`)
171
+ @param blue - (`0...255`)
172
+ */
173
+ rgbToAnsi(red: number, green: number, blue: number): number;
174
+
175
+ /**
176
+ Convert from the RGB HEX color space to the ANSI 16 color space.
177
+
178
+ @param hex - A hexadecimal string containing RGB data.
179
+ */
180
+ hexToAnsi(hex: string): number;
158
181
  }
159
182
 
160
183
  declare const ansiStyles: {
161
- readonly modifier: ansiStyles.Modifier;
162
- readonly color: ansiStyles.ForegroundColor & ansiStyles.ColorBase;
163
- readonly bgColor: ansiStyles.BackgroundColor & ansiStyles.ColorBase;
184
+ readonly modifier: Modifier;
185
+ readonly color: ColorBase & ForegroundColor;
186
+ readonly bgColor: ColorBase & BackgroundColor;
164
187
  readonly codes: ReadonlyMap<number, number>;
165
- } & ansiStyles.BackgroundColor & ansiStyles.ForegroundColor & ansiStyles.Modifier & ansiStyles.ConvertColor;
188
+ } & ForegroundColor & BackgroundColor & Modifier & ConvertColor;
166
189
 
167
- export = ansiStyles;
190
+ export default ansiStyles;
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
- 'use strict';
2
-
3
1
  const ANSI_BACKGROUND_OFFSET = 10;
4
2
 
3
+ const wrapAnsi16 = (offset = 0) => code => `\u001B[${code + offset}m`;
4
+
5
5
  const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
6
6
 
7
7
  const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
@@ -19,7 +19,7 @@ function assembleStyles() {
19
19
  overline: [53, 55],
20
20
  inverse: [7, 27],
21
21
  hidden: [8, 28],
22
- strikethrough: [9, 29]
22
+ strikethrough: [9, 29],
23
23
  },
24
24
  color: {
25
25
  black: [30, 39],
@@ -39,7 +39,7 @@ function assembleStyles() {
39
39
  blueBright: [94, 39],
40
40
  magentaBright: [95, 39],
41
41
  cyanBright: [96, 39],
42
- whiteBright: [97, 39]
42
+ whiteBright: [97, 39],
43
43
  },
44
44
  bgColor: {
45
45
  bgBlack: [40, 49],
@@ -59,8 +59,8 @@ function assembleStyles() {
59
59
  bgBlueBright: [104, 49],
60
60
  bgMagentaBright: [105, 49],
61
61
  bgCyanBright: [106, 49],
62
- bgWhiteBright: [107, 49]
63
- }
62
+ bgWhiteBright: [107, 49],
63
+ },
64
64
  };
65
65
 
66
66
  // Alias bright black as gray (and grey)
@@ -73,7 +73,7 @@ function assembleStyles() {
73
73
  for (const [styleName, style] of Object.entries(group)) {
74
74
  styles[styleName] = {
75
75
  open: `\u001B[${style[0]}m`,
76
- close: `\u001B[${style[1]}m`
76
+ close: `\u001B[${style[1]}m`,
77
77
  };
78
78
 
79
79
  group[styleName] = styles[styleName];
@@ -83,20 +83,22 @@ function assembleStyles() {
83
83
 
84
84
  Object.defineProperty(styles, groupName, {
85
85
  value: group,
86
- enumerable: false
86
+ enumerable: false,
87
87
  });
88
88
  }
89
89
 
90
90
  Object.defineProperty(styles, 'codes', {
91
91
  value: codes,
92
- enumerable: false
92
+ enumerable: false,
93
93
  });
94
94
 
95
95
  styles.color.close = '\u001B[39m';
96
96
  styles.bgColor.close = '\u001B[49m';
97
97
 
98
+ styles.color.ansi = wrapAnsi16();
98
99
  styles.color.ansi256 = wrapAnsi256();
99
100
  styles.color.ansi16m = wrapAnsi16m();
101
+ styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
100
102
  styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
101
103
  styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
102
104
 
@@ -118,47 +120,100 @@ function assembleStyles() {
118
120
  return Math.round(((red - 8) / 247) * 24) + 232;
119
121
  }
120
122
 
121
- return 16 +
122
- (36 * Math.round(red / 255 * 5)) +
123
- (6 * Math.round(green / 255 * 5)) +
124
- Math.round(blue / 255 * 5);
123
+ return 16
124
+ + (36 * Math.round(red / 255 * 5))
125
+ + (6 * Math.round(green / 255 * 5))
126
+ + Math.round(blue / 255 * 5);
125
127
  },
126
- enumerable: false
128
+ enumerable: false,
127
129
  },
128
130
  hexToRgb: {
129
131
  value: hex => {
130
- const matches = /(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(hex.toString(16));
132
+ const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
131
133
  if (!matches) {
132
134
  return [0, 0, 0];
133
135
  }
134
136
 
135
- let {colorString} = matches.groups;
137
+ let [colorString] = matches;
136
138
 
137
139
  if (colorString.length === 3) {
138
- colorString = colorString.split('').map(character => character + character).join('');
140
+ colorString = [...colorString].map(character => character + character).join('');
139
141
  }
140
142
 
141
143
  const integer = Number.parseInt(colorString, 16);
142
144
 
143
145
  return [
146
+ /* eslint-disable no-bitwise */
144
147
  (integer >> 16) & 0xFF,
145
148
  (integer >> 8) & 0xFF,
146
- integer & 0xFF
149
+ integer & 0xFF,
150
+ /* eslint-enable no-bitwise */
147
151
  ];
148
152
  },
149
- enumerable: false
153
+ enumerable: false,
150
154
  },
151
155
  hexToAnsi256: {
152
156
  value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
153
- enumerable: false
154
- }
157
+ enumerable: false,
158
+ },
159
+ ansi256ToAnsi: {
160
+ value: code => {
161
+ if (code < 8) {
162
+ return 30 + code;
163
+ }
164
+
165
+ if (code < 16) {
166
+ return 90 + (code - 8);
167
+ }
168
+
169
+ let red;
170
+ let green;
171
+ let blue;
172
+
173
+ if (code >= 232) {
174
+ red = (((code - 232) * 10) + 8) / 255;
175
+ green = red;
176
+ blue = red;
177
+ } else {
178
+ code -= 16;
179
+
180
+ const remainder = code % 36;
181
+
182
+ red = Math.floor(code / 36) / 5;
183
+ green = Math.floor(remainder / 6) / 5;
184
+ blue = (remainder % 6) / 5;
185
+ }
186
+
187
+ const value = Math.max(red, green, blue) * 2;
188
+
189
+ if (value === 0) {
190
+ return 30;
191
+ }
192
+
193
+ // eslint-disable-next-line no-bitwise
194
+ let result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
195
+
196
+ if (value === 2) {
197
+ result += 60;
198
+ }
199
+
200
+ return result;
201
+ },
202
+ enumerable: false,
203
+ },
204
+ rgbToAnsi: {
205
+ value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
206
+ enumerable: false,
207
+ },
208
+ hexToAnsi: {
209
+ value: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
210
+ enumerable: false,
211
+ },
155
212
  });
156
213
 
157
214
  return styles;
158
215
  }
159
216
 
160
- // Make the export immutable
161
- Object.defineProperty(module, 'exports', {
162
- enumerable: true,
163
- get: assembleStyles
164
- });
217
+ const ansiStyles = assembleStyles();
218
+
219
+ export default ansiStyles;
package/license CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ansi-styles",
3
- "version": "5.2.0",
3
+ "version": "6.1.1",
4
4
  "description": "ANSI escape codes for styling strings in the terminal",
5
5
  "license": "MIT",
6
6
  "repository": "chalk/ansi-styles",
@@ -10,8 +10,10 @@
10
10
  "email": "sindresorhus@gmail.com",
11
11
  "url": "https://sindresorhus.com"
12
12
  },
13
+ "type": "module",
14
+ "exports": "./index.js",
13
15
  "engines": {
14
- "node": ">=10"
16
+ "node": ">=12"
15
17
  },
16
18
  "scripts": {
17
19
  "test": "xo && ava && tsd",
@@ -44,9 +46,9 @@
44
46
  "text"
45
47
  ],
46
48
  "devDependencies": {
47
- "ava": "^2.4.0",
49
+ "ava": "^3.15.0",
48
50
  "svg-term-cli": "^2.1.1",
49
- "tsd": "^0.14.0",
50
- "xo": "^0.37.1"
51
+ "tsd": "^0.19.0",
52
+ "xo": "^0.47.0"
51
53
  }
52
54
  }
package/readme.md CHANGED
@@ -4,20 +4,20 @@
4
4
 
5
5
  You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
6
6
 
7
- <img src="screenshot.svg" width="900">
7
+ ![](screenshot.png)
8
8
 
9
9
  ## Install
10
10
 
11
- ```
12
- $ npm install ansi-styles
11
+ ```sh
12
+ npm install ansi-styles
13
13
  ```
14
14
 
15
15
  ## Usage
16
16
 
17
17
  ```js
18
- const style = require('ansi-styles');
18
+ import styles from 'ansi-styles';
19
19
 
20
- console.log(`${style.green.open}Hello world!${style.green.close}`);
20
+ console.log(`${styles.green.open}Hello world!${styles.green.close}`);
21
21
 
22
22
 
23
23
  // Color conversion between 256/truecolor
@@ -25,8 +25,9 @@ console.log(`${style.green.open}Hello world!${style.green.close}`);
25
25
  // may be degraded to fit the new color palette. This means terminals
26
26
  // that do not support 16 million colors will best-match the
27
27
  // original color.
28
- console.log(`${style.color.ansi256(style.rgbToAnsi256(199, 20, 250))}Hello World${style.color.close}`)
29
- console.log(`${style.color.ansi16m(...style.hexToRgb('#abcdef'))}Hello World${style.color.close}`)
28
+ console.log(`${styles.color.ansi(styles.rgbToAnsi(199, 20, 250))}Hello World${styles.color.close}`)
29
+ console.log(`${styles.color.ansi256(styles.rgbToAnsi256(199, 20, 250))}Hello World${styles.color.close}`)
30
+ console.log(`${styles.color.ansi16m(...styles.hexToRgb('#abcdef'))}Hello World${styles.color.close}`)
30
31
  ```
31
32
 
32
33
  ## API
@@ -89,43 +90,53 @@ Each style has an `open` and `close` property.
89
90
 
90
91
  By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
91
92
 
92
- - `style.modifier`
93
- - `style.color`
94
- - `style.bgColor`
93
+ - `styles.modifier`
94
+ - `styles.color`
95
+ - `styles.bgColor`
95
96
 
96
97
  ###### Example
97
98
 
98
99
  ```js
99
- console.log(style.color.green.open);
100
+ import styles from 'ansi-styles';
101
+
102
+ console.log(styles.color.green.open);
100
103
  ```
101
104
 
102
- Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values.
105
+ Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `styles.codes`, which returns a `Map` with the open codes as keys and close codes as values.
103
106
 
104
107
  ###### Example
105
108
 
106
109
  ```js
107
- console.log(style.codes.get(36));
110
+ import styles from 'ansi-styles';
111
+
112
+ console.log(styles.codes.get(36));
108
113
  //=> 39
109
114
  ```
110
115
 
111
- ## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
116
+ ## 16 / 256 / 16 million (TrueColor) support
112
117
 
113
- `ansi-styles` allows converting between various color formats and ANSI escapes, with support for 256 and 16 million colors.
118
+ `ansi-styles` allows converting between various color formats and ANSI escapes, with support for 16, 256 and [16 million colors](https://gist.github.com/XVilka/8346728).
114
119
 
115
- The following color spaces from `color-convert` are supported:
120
+ The following color spaces are supported:
116
121
 
117
122
  - `rgb`
118
123
  - `hex`
119
124
  - `ansi256`
125
+ - `ansi`
120
126
 
121
127
  To use these, call the associated conversion function with the intended output, for example:
122
128
 
123
129
  ```js
124
- style.color.ansi256(style.rgbToAnsi256(100, 200, 15)); // RGB to 256 color ansi foreground code
125
- style.bgColor.ansi256(style.hexToAnsi256('#C0FFEE')); // HEX to 256 color ansi foreground code
130
+ import styles from 'ansi-styles';
131
+
132
+ styles.color.ansi(styles.rgbToAnsi(100, 200, 15)); // RGB to 16 color ansi foreground code
133
+ styles.bgColor.ansi(styles.hexToAnsi('#C0FFEE')); // HEX to 16 color ansi foreground code
134
+
135
+ styles.color.ansi256(styles.rgbToAnsi256(100, 200, 15)); // RGB to 256 color ansi foreground code
136
+ styles.bgColor.ansi256(styles.hexToAnsi256('#C0FFEE')); // HEX to 256 color ansi foreground code
126
137
 
127
- style.color.ansi16m(100, 200, 15); // RGB to 16 million color foreground code
128
- style.bgColor.ansi16m(...style.hexToRgb('#C0FFEE')); // Hex (RGB) to 16 million color foreground code
138
+ styles.color.ansi16m(100, 200, 15); // RGB to 16 million color foreground code
139
+ styles.bgColor.ansi16m(...styles.hexToRgb('#C0FFEE')); // Hex (RGB) to 16 million color foreground code
129
140
  ```
130
141
 
131
142
  ## Related