ansi-styles 4.0.0 → 4.3.0
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.
- package/index.d.ts +345 -0
- package/index.js +53 -52
- package/package.json +10 -6
- package/readme.md +16 -19
package/index.d.ts
ADDED
@@ -0,0 +1,345 @@
|
|
1
|
+
declare type CSSColor =
|
2
|
+
| 'aliceblue'
|
3
|
+
| 'antiquewhite'
|
4
|
+
| 'aqua'
|
5
|
+
| 'aquamarine'
|
6
|
+
| 'azure'
|
7
|
+
| 'beige'
|
8
|
+
| 'bisque'
|
9
|
+
| 'black'
|
10
|
+
| 'blanchedalmond'
|
11
|
+
| 'blue'
|
12
|
+
| 'blueviolet'
|
13
|
+
| 'brown'
|
14
|
+
| 'burlywood'
|
15
|
+
| 'cadetblue'
|
16
|
+
| 'chartreuse'
|
17
|
+
| 'chocolate'
|
18
|
+
| 'coral'
|
19
|
+
| 'cornflowerblue'
|
20
|
+
| 'cornsilk'
|
21
|
+
| 'crimson'
|
22
|
+
| 'cyan'
|
23
|
+
| 'darkblue'
|
24
|
+
| 'darkcyan'
|
25
|
+
| 'darkgoldenrod'
|
26
|
+
| 'darkgray'
|
27
|
+
| 'darkgreen'
|
28
|
+
| 'darkgrey'
|
29
|
+
| 'darkkhaki'
|
30
|
+
| 'darkmagenta'
|
31
|
+
| 'darkolivegreen'
|
32
|
+
| 'darkorange'
|
33
|
+
| 'darkorchid'
|
34
|
+
| 'darkred'
|
35
|
+
| 'darksalmon'
|
36
|
+
| 'darkseagreen'
|
37
|
+
| 'darkslateblue'
|
38
|
+
| 'darkslategray'
|
39
|
+
| 'darkslategrey'
|
40
|
+
| 'darkturquoise'
|
41
|
+
| 'darkviolet'
|
42
|
+
| 'deeppink'
|
43
|
+
| 'deepskyblue'
|
44
|
+
| 'dimgray'
|
45
|
+
| 'dimgrey'
|
46
|
+
| 'dodgerblue'
|
47
|
+
| 'firebrick'
|
48
|
+
| 'floralwhite'
|
49
|
+
| 'forestgreen'
|
50
|
+
| 'fuchsia'
|
51
|
+
| 'gainsboro'
|
52
|
+
| 'ghostwhite'
|
53
|
+
| 'gold'
|
54
|
+
| 'goldenrod'
|
55
|
+
| 'gray'
|
56
|
+
| 'green'
|
57
|
+
| 'greenyellow'
|
58
|
+
| 'grey'
|
59
|
+
| 'honeydew'
|
60
|
+
| 'hotpink'
|
61
|
+
| 'indianred'
|
62
|
+
| 'indigo'
|
63
|
+
| 'ivory'
|
64
|
+
| 'khaki'
|
65
|
+
| 'lavender'
|
66
|
+
| 'lavenderblush'
|
67
|
+
| 'lawngreen'
|
68
|
+
| 'lemonchiffon'
|
69
|
+
| 'lightblue'
|
70
|
+
| 'lightcoral'
|
71
|
+
| 'lightcyan'
|
72
|
+
| 'lightgoldenrodyellow'
|
73
|
+
| 'lightgray'
|
74
|
+
| 'lightgreen'
|
75
|
+
| 'lightgrey'
|
76
|
+
| 'lightpink'
|
77
|
+
| 'lightsalmon'
|
78
|
+
| 'lightseagreen'
|
79
|
+
| 'lightskyblue'
|
80
|
+
| 'lightslategray'
|
81
|
+
| 'lightslategrey'
|
82
|
+
| 'lightsteelblue'
|
83
|
+
| 'lightyellow'
|
84
|
+
| 'lime'
|
85
|
+
| 'limegreen'
|
86
|
+
| 'linen'
|
87
|
+
| 'magenta'
|
88
|
+
| 'maroon'
|
89
|
+
| 'mediumaquamarine'
|
90
|
+
| 'mediumblue'
|
91
|
+
| 'mediumorchid'
|
92
|
+
| 'mediumpurple'
|
93
|
+
| 'mediumseagreen'
|
94
|
+
| 'mediumslateblue'
|
95
|
+
| 'mediumspringgreen'
|
96
|
+
| 'mediumturquoise'
|
97
|
+
| 'mediumvioletred'
|
98
|
+
| 'midnightblue'
|
99
|
+
| 'mintcream'
|
100
|
+
| 'mistyrose'
|
101
|
+
| 'moccasin'
|
102
|
+
| 'navajowhite'
|
103
|
+
| 'navy'
|
104
|
+
| 'oldlace'
|
105
|
+
| 'olive'
|
106
|
+
| 'olivedrab'
|
107
|
+
| 'orange'
|
108
|
+
| 'orangered'
|
109
|
+
| 'orchid'
|
110
|
+
| 'palegoldenrod'
|
111
|
+
| 'palegreen'
|
112
|
+
| 'paleturquoise'
|
113
|
+
| 'palevioletred'
|
114
|
+
| 'papayawhip'
|
115
|
+
| 'peachpuff'
|
116
|
+
| 'peru'
|
117
|
+
| 'pink'
|
118
|
+
| 'plum'
|
119
|
+
| 'powderblue'
|
120
|
+
| 'purple'
|
121
|
+
| 'rebeccapurple'
|
122
|
+
| 'red'
|
123
|
+
| 'rosybrown'
|
124
|
+
| 'royalblue'
|
125
|
+
| 'saddlebrown'
|
126
|
+
| 'salmon'
|
127
|
+
| 'sandybrown'
|
128
|
+
| 'seagreen'
|
129
|
+
| 'seashell'
|
130
|
+
| 'sienna'
|
131
|
+
| 'silver'
|
132
|
+
| 'skyblue'
|
133
|
+
| 'slateblue'
|
134
|
+
| 'slategray'
|
135
|
+
| 'slategrey'
|
136
|
+
| 'snow'
|
137
|
+
| 'springgreen'
|
138
|
+
| 'steelblue'
|
139
|
+
| 'tan'
|
140
|
+
| 'teal'
|
141
|
+
| 'thistle'
|
142
|
+
| 'tomato'
|
143
|
+
| 'turquoise'
|
144
|
+
| 'violet'
|
145
|
+
| 'wheat'
|
146
|
+
| 'white'
|
147
|
+
| 'whitesmoke'
|
148
|
+
| 'yellow'
|
149
|
+
| 'yellowgreen';
|
150
|
+
|
151
|
+
declare namespace ansiStyles {
|
152
|
+
interface ColorConvert {
|
153
|
+
/**
|
154
|
+
The RGB color space.
|
155
|
+
|
156
|
+
@param red - (`0`-`255`)
|
157
|
+
@param green - (`0`-`255`)
|
158
|
+
@param blue - (`0`-`255`)
|
159
|
+
*/
|
160
|
+
rgb(red: number, green: number, blue: number): string;
|
161
|
+
|
162
|
+
/**
|
163
|
+
The RGB HEX color space.
|
164
|
+
|
165
|
+
@param hex - A hexadecimal string containing RGB data.
|
166
|
+
*/
|
167
|
+
hex(hex: string): string;
|
168
|
+
|
169
|
+
/**
|
170
|
+
@param keyword - A CSS color name.
|
171
|
+
*/
|
172
|
+
keyword(keyword: CSSColor): string;
|
173
|
+
|
174
|
+
/**
|
175
|
+
The HSL color space.
|
176
|
+
|
177
|
+
@param hue - (`0`-`360`)
|
178
|
+
@param saturation - (`0`-`100`)
|
179
|
+
@param lightness - (`0`-`100`)
|
180
|
+
*/
|
181
|
+
hsl(hue: number, saturation: number, lightness: number): string;
|
182
|
+
|
183
|
+
/**
|
184
|
+
The HSV color space.
|
185
|
+
|
186
|
+
@param hue - (`0`-`360`)
|
187
|
+
@param saturation - (`0`-`100`)
|
188
|
+
@param value - (`0`-`100`)
|
189
|
+
*/
|
190
|
+
hsv(hue: number, saturation: number, value: number): string;
|
191
|
+
|
192
|
+
/**
|
193
|
+
The HSV color space.
|
194
|
+
|
195
|
+
@param hue - (`0`-`360`)
|
196
|
+
@param whiteness - (`0`-`100`)
|
197
|
+
@param blackness - (`0`-`100`)
|
198
|
+
*/
|
199
|
+
hwb(hue: number, whiteness: number, blackness: number): string;
|
200
|
+
|
201
|
+
/**
|
202
|
+
Use a [4-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#3/4-bit) to set text color.
|
203
|
+
*/
|
204
|
+
ansi(ansi: number): string;
|
205
|
+
|
206
|
+
/**
|
207
|
+
Use an [8-bit unsigned number](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit) to set text color.
|
208
|
+
*/
|
209
|
+
ansi256(ansi: number): string;
|
210
|
+
}
|
211
|
+
|
212
|
+
interface CSPair {
|
213
|
+
/**
|
214
|
+
The ANSI terminal control sequence for starting this style.
|
215
|
+
*/
|
216
|
+
readonly open: string;
|
217
|
+
|
218
|
+
/**
|
219
|
+
The ANSI terminal control sequence for ending this style.
|
220
|
+
*/
|
221
|
+
readonly close: string;
|
222
|
+
}
|
223
|
+
|
224
|
+
interface ColorBase {
|
225
|
+
readonly ansi: ColorConvert;
|
226
|
+
readonly ansi256: ColorConvert;
|
227
|
+
readonly ansi16m: ColorConvert;
|
228
|
+
|
229
|
+
/**
|
230
|
+
The ANSI terminal control sequence for ending this color.
|
231
|
+
*/
|
232
|
+
readonly close: string;
|
233
|
+
}
|
234
|
+
|
235
|
+
interface Modifier {
|
236
|
+
/**
|
237
|
+
Resets the current color chain.
|
238
|
+
*/
|
239
|
+
readonly reset: CSPair;
|
240
|
+
|
241
|
+
/**
|
242
|
+
Make text bold.
|
243
|
+
*/
|
244
|
+
readonly bold: CSPair;
|
245
|
+
|
246
|
+
/**
|
247
|
+
Emitting only a small amount of light.
|
248
|
+
*/
|
249
|
+
readonly dim: CSPair;
|
250
|
+
|
251
|
+
/**
|
252
|
+
Make text italic. (Not widely supported)
|
253
|
+
*/
|
254
|
+
readonly italic: CSPair;
|
255
|
+
|
256
|
+
/**
|
257
|
+
Make text underline. (Not widely supported)
|
258
|
+
*/
|
259
|
+
readonly underline: CSPair;
|
260
|
+
|
261
|
+
/**
|
262
|
+
Inverse background and foreground colors.
|
263
|
+
*/
|
264
|
+
readonly inverse: CSPair;
|
265
|
+
|
266
|
+
/**
|
267
|
+
Prints the text, but makes it invisible.
|
268
|
+
*/
|
269
|
+
readonly hidden: CSPair;
|
270
|
+
|
271
|
+
/**
|
272
|
+
Puts a horizontal line through the center of the text. (Not widely supported)
|
273
|
+
*/
|
274
|
+
readonly strikethrough: CSPair;
|
275
|
+
}
|
276
|
+
|
277
|
+
interface ForegroundColor {
|
278
|
+
readonly black: CSPair;
|
279
|
+
readonly red: CSPair;
|
280
|
+
readonly green: CSPair;
|
281
|
+
readonly yellow: CSPair;
|
282
|
+
readonly blue: CSPair;
|
283
|
+
readonly cyan: CSPair;
|
284
|
+
readonly magenta: CSPair;
|
285
|
+
readonly white: CSPair;
|
286
|
+
|
287
|
+
/**
|
288
|
+
Alias for `blackBright`.
|
289
|
+
*/
|
290
|
+
readonly gray: CSPair;
|
291
|
+
|
292
|
+
/**
|
293
|
+
Alias for `blackBright`.
|
294
|
+
*/
|
295
|
+
readonly grey: CSPair;
|
296
|
+
|
297
|
+
readonly blackBright: CSPair;
|
298
|
+
readonly redBright: CSPair;
|
299
|
+
readonly greenBright: CSPair;
|
300
|
+
readonly yellowBright: CSPair;
|
301
|
+
readonly blueBright: CSPair;
|
302
|
+
readonly cyanBright: CSPair;
|
303
|
+
readonly magentaBright: CSPair;
|
304
|
+
readonly whiteBright: CSPair;
|
305
|
+
}
|
306
|
+
|
307
|
+
interface BackgroundColor {
|
308
|
+
readonly bgBlack: CSPair;
|
309
|
+
readonly bgRed: CSPair;
|
310
|
+
readonly bgGreen: CSPair;
|
311
|
+
readonly bgYellow: CSPair;
|
312
|
+
readonly bgBlue: CSPair;
|
313
|
+
readonly bgCyan: CSPair;
|
314
|
+
readonly bgMagenta: CSPair;
|
315
|
+
readonly bgWhite: CSPair;
|
316
|
+
|
317
|
+
/**
|
318
|
+
Alias for `bgBlackBright`.
|
319
|
+
*/
|
320
|
+
readonly bgGray: CSPair;
|
321
|
+
|
322
|
+
/**
|
323
|
+
Alias for `bgBlackBright`.
|
324
|
+
*/
|
325
|
+
readonly bgGrey: CSPair;
|
326
|
+
|
327
|
+
readonly bgBlackBright: CSPair;
|
328
|
+
readonly bgRedBright: CSPair;
|
329
|
+
readonly bgGreenBright: CSPair;
|
330
|
+
readonly bgYellowBright: CSPair;
|
331
|
+
readonly bgBlueBright: CSPair;
|
332
|
+
readonly bgCyanBright: CSPair;
|
333
|
+
readonly bgMagentaBright: CSPair;
|
334
|
+
readonly bgWhiteBright: CSPair;
|
335
|
+
}
|
336
|
+
}
|
337
|
+
|
338
|
+
declare const ansiStyles: {
|
339
|
+
readonly modifier: ansiStyles.Modifier;
|
340
|
+
readonly color: ansiStyles.ForegroundColor & ansiStyles.ColorBase;
|
341
|
+
readonly bgColor: ansiStyles.BackgroundColor & ansiStyles.ColorBase;
|
342
|
+
readonly codes: ReadonlyMap<number, number>;
|
343
|
+
} & ansiStyles.BackgroundColor & ansiStyles.ForegroundColor & ansiStyles.Modifier;
|
344
|
+
|
345
|
+
export = ansiStyles;
|
package/index.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
'use strict';
|
2
|
-
const colorConvert = require('color-convert');
|
3
2
|
|
4
3
|
const wrapAnsi16 = (fn, offset) => (...args) => {
|
5
4
|
const code = fn(...args);
|
@@ -16,6 +15,49 @@ const wrapAnsi16m = (fn, offset) => (...args) => {
|
|
16
15
|
return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
|
17
16
|
};
|
18
17
|
|
18
|
+
const ansi2ansi = n => n;
|
19
|
+
const rgb2rgb = (r, g, b) => [r, g, b];
|
20
|
+
|
21
|
+
const setLazyProperty = (object, property, get) => {
|
22
|
+
Object.defineProperty(object, property, {
|
23
|
+
get: () => {
|
24
|
+
const value = get();
|
25
|
+
|
26
|
+
Object.defineProperty(object, property, {
|
27
|
+
value,
|
28
|
+
enumerable: true,
|
29
|
+
configurable: true
|
30
|
+
});
|
31
|
+
|
32
|
+
return value;
|
33
|
+
},
|
34
|
+
enumerable: true,
|
35
|
+
configurable: true
|
36
|
+
});
|
37
|
+
};
|
38
|
+
|
39
|
+
/** @type {typeof import('color-convert')} */
|
40
|
+
let colorConvert;
|
41
|
+
const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => {
|
42
|
+
if (colorConvert === undefined) {
|
43
|
+
colorConvert = require('color-convert');
|
44
|
+
}
|
45
|
+
|
46
|
+
const offset = isBackground ? 10 : 0;
|
47
|
+
const styles = {};
|
48
|
+
|
49
|
+
for (const [sourceSpace, suite] of Object.entries(colorConvert)) {
|
50
|
+
const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace;
|
51
|
+
if (sourceSpace === targetSpace) {
|
52
|
+
styles[name] = wrap(identity, offset);
|
53
|
+
} else if (typeof suite === 'object') {
|
54
|
+
styles[name] = wrap(suite[targetSpace], offset);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
return styles;
|
59
|
+
};
|
60
|
+
|
19
61
|
function assembleStyles() {
|
20
62
|
const codes = new Map();
|
21
63
|
const styles = {
|
@@ -94,63 +136,22 @@ function assembleStyles() {
|
|
94
136
|
value: group,
|
95
137
|
enumerable: false
|
96
138
|
});
|
97
|
-
|
98
|
-
Object.defineProperty(styles, 'codes', {
|
99
|
-
value: codes,
|
100
|
-
enumerable: false
|
101
|
-
});
|
102
139
|
}
|
103
140
|
|
104
|
-
|
105
|
-
|
141
|
+
Object.defineProperty(styles, 'codes', {
|
142
|
+
value: codes,
|
143
|
+
enumerable: false
|
144
|
+
});
|
106
145
|
|
107
146
|
styles.color.close = '\u001B[39m';
|
108
147
|
styles.bgColor.close = '\u001B[49m';
|
109
148
|
|
110
|
-
styles.color
|
111
|
-
|
112
|
-
|
113
|
-
styles.
|
114
|
-
|
115
|
-
|
116
|
-
styles.color.ansi16m = {
|
117
|
-
rgb: wrapAnsi16m(rgb2rgb, 0)
|
118
|
-
};
|
119
|
-
|
120
|
-
styles.bgColor.ansi = {
|
121
|
-
ansi: wrapAnsi16(ansi2ansi, 10)
|
122
|
-
};
|
123
|
-
styles.bgColor.ansi256 = {
|
124
|
-
ansi256: wrapAnsi256(ansi2ansi, 10)
|
125
|
-
};
|
126
|
-
styles.bgColor.ansi16m = {
|
127
|
-
rgb: wrapAnsi16m(rgb2rgb, 10)
|
128
|
-
};
|
129
|
-
|
130
|
-
for (let [key, suite] of Object.entries(colorConvert)) {
|
131
|
-
if (typeof suite !== 'object') {
|
132
|
-
continue;
|
133
|
-
}
|
134
|
-
|
135
|
-
if (key === 'ansi16') {
|
136
|
-
key = 'ansi';
|
137
|
-
}
|
138
|
-
|
139
|
-
if ('ansi16' in suite) {
|
140
|
-
styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0);
|
141
|
-
styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10);
|
142
|
-
}
|
143
|
-
|
144
|
-
if ('ansi256' in suite) {
|
145
|
-
styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0);
|
146
|
-
styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10);
|
147
|
-
}
|
148
|
-
|
149
|
-
if ('rgb' in suite) {
|
150
|
-
styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0);
|
151
|
-
styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10);
|
152
|
-
}
|
153
|
-
}
|
149
|
+
setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
|
150
|
+
setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
|
151
|
+
setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
|
152
|
+
setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
|
153
|
+
setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
|
154
|
+
setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
|
154
155
|
|
155
156
|
return styles;
|
156
157
|
}
|
package/package.json
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "ansi-styles",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.3.0",
|
4
4
|
"description": "ANSI escape codes for styling strings in the terminal",
|
5
5
|
"license": "MIT",
|
6
6
|
"repository": "chalk/ansi-styles",
|
7
|
+
"funding": "https://github.com/chalk/ansi-styles?sponsor=1",
|
7
8
|
"author": {
|
8
9
|
"name": "Sindre Sorhus",
|
9
10
|
"email": "sindresorhus@gmail.com",
|
@@ -13,11 +14,12 @@
|
|
13
14
|
"node": ">=8"
|
14
15
|
},
|
15
16
|
"scripts": {
|
16
|
-
"test": "xo && ava",
|
17
|
+
"test": "xo && ava && tsd",
|
17
18
|
"screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor"
|
18
19
|
},
|
19
20
|
"files": [
|
20
|
-
"index.js"
|
21
|
+
"index.js",
|
22
|
+
"index.d.ts"
|
21
23
|
],
|
22
24
|
"keywords": [
|
23
25
|
"ansi",
|
@@ -42,11 +44,13 @@
|
|
42
44
|
"text"
|
43
45
|
],
|
44
46
|
"dependencies": {
|
45
|
-
"color-convert": "^2.0.
|
47
|
+
"color-convert": "^2.0.1"
|
46
48
|
},
|
47
49
|
"devDependencies": {
|
48
|
-
"
|
50
|
+
"@types/color-convert": "^1.9.0",
|
51
|
+
"ava": "^2.3.0",
|
49
52
|
"svg-term-cli": "^2.1.1",
|
50
|
-
"
|
53
|
+
"tsd": "^0.11.0",
|
54
|
+
"xo": "^0.25.3"
|
51
55
|
}
|
52
56
|
}
|
package/readme.md
CHANGED
@@ -1,19 +1,17 @@
|
|
1
1
|
# ansi-styles [](https://travis-ci.org/chalk/ansi-styles)
|
2
2
|
|
3
|
-
> [ANSI escape codes](
|
3
|
+
> [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
|
4
4
|
|
5
5
|
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
|
6
6
|
|
7
7
|
<img src="screenshot.svg" width="900">
|
8
8
|
|
9
|
-
|
10
9
|
## Install
|
11
10
|
|
12
11
|
```
|
13
12
|
$ npm install ansi-styles
|
14
13
|
```
|
15
14
|
|
16
|
-
|
17
15
|
## Usage
|
18
16
|
|
19
17
|
```js
|
@@ -29,14 +27,13 @@ console.log(`${style.green.open}Hello world!${style.green.close}`);
|
|
29
27
|
// original color.
|
30
28
|
console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close);
|
31
29
|
console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close);
|
32
|
-
console.log(style.color.ansi16m.hex('#
|
30
|
+
console.log(style.color.ansi16m.hex('#abcdef') + 'Hello world!' + style.color.close);
|
33
31
|
```
|
34
32
|
|
35
33
|
## API
|
36
34
|
|
37
35
|
Each style has an `open` and `close` property.
|
38
36
|
|
39
|
-
|
40
37
|
## Styles
|
41
38
|
|
42
39
|
### Modifiers
|
@@ -88,7 +85,6 @@ Each style has an `open` and `close` property.
|
|
88
85
|
- `bgCyanBright`
|
89
86
|
- `bgWhiteBright`
|
90
87
|
|
91
|
-
|
92
88
|
## Advanced usage
|
93
89
|
|
94
90
|
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.
|
@@ -112,11 +108,21 @@ console.log(style.codes.get(36));
|
|
112
108
|
//=> 39
|
113
109
|
```
|
114
110
|
|
115
|
-
|
116
111
|
## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728)
|
117
112
|
|
118
113
|
`ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors.
|
119
114
|
|
115
|
+
The following color spaces from `color-convert` are supported:
|
116
|
+
|
117
|
+
- `rgb`
|
118
|
+
- `hex`
|
119
|
+
- `keyword`
|
120
|
+
- `hsl`
|
121
|
+
- `hsv`
|
122
|
+
- `hwb`
|
123
|
+
- `ansi`
|
124
|
+
- `ansi256`
|
125
|
+
|
120
126
|
To use these, call the associated conversion function with the intended output, for example:
|
121
127
|
|
122
128
|
```js
|
@@ -130,26 +136,17 @@ style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground
|
|
130
136
|
style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code
|
131
137
|
```
|
132
138
|
|
133
|
-
|
134
139
|
## Related
|
135
140
|
|
136
141
|
- [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal
|
137
142
|
|
138
|
-
|
139
143
|
## Maintainers
|
140
144
|
|
141
145
|
- [Sindre Sorhus](https://github.com/sindresorhus)
|
142
146
|
- [Josh Junon](https://github.com/qix-)
|
143
147
|
|
148
|
+
## For enterprise
|
144
149
|
|
145
|
-
|
150
|
+
Available as part of the Tidelift Subscription.
|
146
151
|
|
147
|
-
|
148
|
-
<b>
|
149
|
-
<a href="https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
|
150
|
-
</b>
|
151
|
-
<br>
|
152
|
-
<sub>
|
153
|
-
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
154
|
-
</sub>
|
155
|
-
</div>
|
152
|
+
The maintainers of `ansi-styles` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-ansi-styles?utm_source=npm-ansi-styles&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|