ansi-styles 6.1.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.
- package/index.d.ts +1 -1
- package/index.js +25 -22
- package/package.json +3 -3
- package/readme.md +3 -3
package/index.d.ts
CHANGED
package/index.js
CHANGED
@@ -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,13 +83,13 @@ 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';
|
@@ -120,39 +120,41 @@ function assembleStyles() {
|
|
120
120
|
return Math.round(((red - 8) / 247) * 24) + 232;
|
121
121
|
}
|
122
122
|
|
123
|
-
return 16
|
124
|
-
(36 * Math.round(red / 255 * 5))
|
125
|
-
(6 * Math.round(green / 255 * 5))
|
126
|
-
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);
|
127
127
|
},
|
128
|
-
enumerable: false
|
128
|
+
enumerable: false,
|
129
129
|
},
|
130
130
|
hexToRgb: {
|
131
131
|
value: hex => {
|
132
|
-
const matches = /
|
132
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
133
133
|
if (!matches) {
|
134
134
|
return [0, 0, 0];
|
135
135
|
}
|
136
136
|
|
137
|
-
let
|
137
|
+
let [colorString] = matches;
|
138
138
|
|
139
139
|
if (colorString.length === 3) {
|
140
|
-
colorString = colorString.
|
140
|
+
colorString = [...colorString].map(character => character + character).join('');
|
141
141
|
}
|
142
142
|
|
143
143
|
const integer = Number.parseInt(colorString, 16);
|
144
144
|
|
145
145
|
return [
|
146
|
+
/* eslint-disable no-bitwise */
|
146
147
|
(integer >> 16) & 0xFF,
|
147
148
|
(integer >> 8) & 0xFF,
|
148
|
-
integer & 0xFF
|
149
|
+
integer & 0xFF,
|
150
|
+
/* eslint-enable no-bitwise */
|
149
151
|
];
|
150
152
|
},
|
151
|
-
enumerable: false
|
153
|
+
enumerable: false,
|
152
154
|
},
|
153
155
|
hexToAnsi256: {
|
154
156
|
value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
155
|
-
enumerable: false
|
157
|
+
enumerable: false,
|
156
158
|
},
|
157
159
|
ansi256ToAnsi: {
|
158
160
|
value: code => {
|
@@ -188,6 +190,7 @@ function assembleStyles() {
|
|
188
190
|
return 30;
|
189
191
|
}
|
190
192
|
|
193
|
+
// eslint-disable-next-line no-bitwise
|
191
194
|
let result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
|
192
195
|
|
193
196
|
if (value === 2) {
|
@@ -196,16 +199,16 @@ function assembleStyles() {
|
|
196
199
|
|
197
200
|
return result;
|
198
201
|
},
|
199
|
-
enumerable: false
|
202
|
+
enumerable: false,
|
200
203
|
},
|
201
204
|
rgbToAnsi: {
|
202
205
|
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
203
|
-
enumerable: false
|
206
|
+
enumerable: false,
|
204
207
|
},
|
205
208
|
hexToAnsi: {
|
206
209
|
value: hex => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
207
|
-
enumerable: false
|
208
|
-
}
|
210
|
+
enumerable: false,
|
211
|
+
},
|
209
212
|
});
|
210
213
|
|
211
214
|
return styles;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "ansi-styles",
|
3
|
-
"version": "6.1.
|
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",
|
@@ -48,7 +48,7 @@
|
|
48
48
|
"devDependencies": {
|
49
49
|
"ava": "^3.15.0",
|
50
50
|
"svg-term-cli": "^2.1.1",
|
51
|
-
"tsd": "^0.
|
52
|
-
"xo": "^0.
|
51
|
+
"tsd": "^0.19.0",
|
52
|
+
"xo": "^0.47.0"
|
53
53
|
}
|
54
54
|
}
|
package/readme.md
CHANGED
@@ -4,12 +4,12 @@
|
|
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
|
+

|
8
8
|
|
9
9
|
## Install
|
10
10
|
|
11
|
-
```
|
12
|
-
|
11
|
+
```sh
|
12
|
+
npm install ansi-styles
|
13
13
|
```
|
14
14
|
|
15
15
|
## Usage
|