ansi-styles 1.1.0 → 2.0.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.js +49 -33
- package/package.json +1 -1
- package/readme.md +19 -3
package/index.js
CHANGED
@@ -1,40 +1,56 @@
|
|
1
1
|
'use strict';
|
2
|
-
var styles = module.exports;
|
3
2
|
|
4
|
-
var
|
5
|
-
|
3
|
+
var styles = module.exports = {
|
4
|
+
modifiers: {
|
5
|
+
reset: [0, 0],
|
6
|
+
bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
|
7
|
+
dim: [2, 22],
|
8
|
+
italic: [3, 23],
|
9
|
+
underline: [4, 24],
|
10
|
+
inverse: [7, 27],
|
11
|
+
hidden: [8, 28],
|
12
|
+
strikethrough: [9, 29]
|
13
|
+
},
|
14
|
+
colors: {
|
15
|
+
black: [30, 39],
|
16
|
+
red: [31, 39],
|
17
|
+
green: [32, 39],
|
18
|
+
yellow: [33, 39],
|
19
|
+
blue: [34, 39],
|
20
|
+
magenta: [35, 39],
|
21
|
+
cyan: [36, 39],
|
22
|
+
white: [37, 39],
|
23
|
+
gray: [90, 39]
|
24
|
+
},
|
25
|
+
bgColors: {
|
26
|
+
bgBlack: [40, 49],
|
27
|
+
bgRed: [41, 49],
|
28
|
+
bgGreen: [42, 49],
|
29
|
+
bgYellow: [43, 49],
|
30
|
+
bgBlue: [44, 49],
|
31
|
+
bgMagenta: [45, 49],
|
32
|
+
bgCyan: [46, 49],
|
33
|
+
bgWhite: [47, 49]
|
34
|
+
}
|
35
|
+
};
|
6
36
|
|
7
|
-
|
8
|
-
|
9
|
-
italic: [3, 23],
|
10
|
-
underline: [4, 24],
|
11
|
-
inverse: [7, 27],
|
12
|
-
hidden: [8, 28],
|
13
|
-
strikethrough: [9, 29],
|
37
|
+
// fix humans
|
38
|
+
styles.colors.grey = styles.colors.gray;
|
14
39
|
|
15
|
-
|
16
|
-
|
17
|
-
green: [32, 39],
|
18
|
-
yellow: [33, 39],
|
19
|
-
blue: [34, 39],
|
20
|
-
magenta: [35, 39],
|
21
|
-
cyan: [36, 39],
|
22
|
-
white: [37, 39],
|
23
|
-
gray: [90, 39],
|
40
|
+
Object.keys(styles).forEach(function (groupName) {
|
41
|
+
var group = styles[groupName];
|
24
42
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
};
|
43
|
+
Object.keys(group).forEach(function (styleName) {
|
44
|
+
var style = group[styleName];
|
45
|
+
|
46
|
+
styles[styleName] = group[styleName] = {
|
47
|
+
open: '\u001b[' + style[0] + 'm',
|
48
|
+
close: '\u001b[' + style[1] + 'm'
|
49
|
+
};
|
50
|
+
});
|
34
51
|
|
35
|
-
Object.
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
style.close = '\u001b[' + val[1] + 'm';
|
52
|
+
Object.defineProperty(styles, groupName, {
|
53
|
+
value: group,
|
54
|
+
enumerable: false
|
55
|
+
});
|
40
56
|
});
|
package/package.json
CHANGED
package/readme.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
You probably want the higher-level [chalk](https://github.com/sindresorhus/chalk) module for styling your strings.
|
6
6
|
|
7
|
-

|
8
8
|
|
9
9
|
|
10
10
|
## Install
|
@@ -30,7 +30,7 @@ Each style has an `open` and `close` property.
|
|
30
30
|
|
31
31
|
## Styles
|
32
32
|
|
33
|
-
###
|
33
|
+
### Modifiers
|
34
34
|
|
35
35
|
- `reset`
|
36
36
|
- `bold`
|
@@ -41,7 +41,7 @@ Each style has an `open` and `close` property.
|
|
41
41
|
- `hidden`
|
42
42
|
- `strikethrough` *(not widely supported)*
|
43
43
|
|
44
|
-
###
|
44
|
+
### Colors
|
45
45
|
|
46
46
|
- `black`
|
47
47
|
- `red`
|
@@ -65,6 +65,22 @@ Each style has an `open` and `close` property.
|
|
65
65
|
- `bgWhite`
|
66
66
|
|
67
67
|
|
68
|
+
## Advanced usage
|
69
|
+
|
70
|
+
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.
|
71
|
+
|
72
|
+
- `ansi.modifiers`
|
73
|
+
- `ansi.colors`
|
74
|
+
- `ansi.bgColors`
|
75
|
+
|
76
|
+
|
77
|
+
###### Example
|
78
|
+
|
79
|
+
```js
|
80
|
+
console.log(ansi.colors.green.open);
|
81
|
+
```
|
82
|
+
|
83
|
+
|
68
84
|
## License
|
69
85
|
|
70
86
|
MIT © [Sindre Sorhus](http://sindresorhus.com)
|