ansi-styles 0.1.2 → 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 ADDED
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
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
+ };
36
+
37
+ // fix humans
38
+ styles.colors.grey = styles.colors.gray;
39
+
40
+ Object.keys(styles).forEach(function (groupName) {
41
+ var group = styles[groupName];
42
+
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
+ });
51
+
52
+ Object.defineProperty(styles, groupName, {
53
+ value: group,
54
+ enumerable: false
55
+ });
56
+ });
package/package.json CHANGED
@@ -1,7 +1,23 @@
1
1
  {
2
2
  "name": "ansi-styles",
3
- "version": "0.1.2",
4
- "description": "ANSI escape codes for colorizing strings in the terminal",
3
+ "version": "2.0.0",
4
+ "description": "ANSI escape codes for styling strings in the terminal",
5
+ "license": "MIT",
6
+ "repository": "sindresorhus/ansi-styles",
7
+ "author": {
8
+ "name": "Sindre Sorhus",
9
+ "email": "sindresorhus@gmail.com",
10
+ "url": "http://sindresorhus.com"
11
+ },
12
+ "engines": {
13
+ "node": ">=0.10.0"
14
+ },
15
+ "scripts": {
16
+ "test": "mocha"
17
+ },
18
+ "files": [
19
+ "index.js"
20
+ ],
5
21
  "keywords": [
6
22
  "ansi",
7
23
  "styles",
@@ -24,29 +40,7 @@
24
40
  "command-line",
25
41
  "text"
26
42
  ],
27
- "homepage": "https://github.com/sindresorhus/ansi-styles",
28
- "bugs": "https://github.com/sindresorhus/ansi-styles/issues",
29
- "license": "MIT",
30
- "author": {
31
- "name": "Sindre Sorhus",
32
- "email": "sindresorhus@gmail.com",
33
- "url": "http://sindresorhus.com"
34
- },
35
- "files": [
36
- "ansi-styles.js"
37
- ],
38
- "main": "ansi-styles",
39
- "repository": {
40
- "type": "git",
41
- "url": "git://github.com/sindresorhus/ansi-styles.git"
42
- },
43
- "scripts": {
44
- "test": "mocha"
45
- },
46
43
  "devDependencies": {
47
- "mocha": "~1.12.0"
48
- },
49
- "engines": {
50
- "node": ">=0.8.0"
44
+ "mocha": "*"
51
45
  }
52
46
  }
package/readme.md CHANGED
@@ -1,76 +1,86 @@
1
- # ansi-styles [![Build Status](https://secure.travis-ci.org/sindresorhus/ansi-styles.png?branch=master)](http://travis-ci.org/sindresorhus/ansi-styles)
1
+ # ansi-styles [![Build Status](https://travis-ci.org/sindresorhus/ansi-styles.svg?branch=master)](https://travis-ci.org/sindresorhus/ansi-styles)
2
2
 
3
- > ANSI escape codes for colorizing strings in the terminal.
3
+ > [ANSI escape codes](http://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/sindresorhus/chalk) module for styling your strings.
6
6
 
7
- ![screenshot](screenshot.png)
7
+ ![](screenshot.png)
8
8
 
9
9
 
10
10
  ## Install
11
11
 
12
- Install with [npm](https://npmjs.org/package/ansi-styles): `npm install --save ansi-styles`
13
-
12
+ ```sh
13
+ $ npm install --save ansi-styles
14
+ ```
14
15
 
15
- ## Example
16
16
 
17
- Generates the above screenshot.
17
+ ## Usage
18
18
 
19
19
  ```js
20
20
  var ansi = require('ansi-styles');
21
21
 
22
- console.log(ansi.green + 'Styles:' + ansi.reset + '\n');
22
+ console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
23
+ ```
23
24
 
24
- Object.keys(ansi).forEach(function (el) {
25
- var style = ansi[el];
26
25
 
27
- if (/^bg[^B]/.test(el)) {
28
- style = ansi.black + style;
29
- }
26
+ ## API
30
27
 
31
- process.stdout.write(style + el + ansi.reset + ' ');
32
- });
33
- ```
28
+ Each style has an `open` and `close` property.
34
29
 
35
30
 
36
31
  ## Styles
37
32
 
38
- ### General
39
-
40
- - reset
41
- - bold
42
- - italic
43
- - underline
44
- - blink
45
- - inverse
46
- - strikethrough
47
-
48
- ### Text colors
49
-
50
- - black
51
- - red
52
- - green
53
- - yellow
54
- - blue
55
- - magenta
56
- - cyan
57
- - white
58
- - default
59
- - gray
33
+ ### Modifiers
34
+
35
+ - `reset`
36
+ - `bold`
37
+ - `dim`
38
+ - `italic` *(not widely supported)*
39
+ - `underline`
40
+ - `inverse`
41
+ - `hidden`
42
+ - `strikethrough` *(not widely supported)*
43
+
44
+ ### Colors
45
+
46
+ - `black`
47
+ - `red`
48
+ - `green`
49
+ - `yellow`
50
+ - `blue`
51
+ - `magenta`
52
+ - `cyan`
53
+ - `white`
54
+ - `gray`
60
55
 
61
56
  ### Background colors
62
57
 
63
- - bgBlack
64
- - bgRed
65
- - bgGreen
66
- - bgYellow
67
- - bgBlue
68
- - bgMagenta
69
- - bgCyan
70
- - bgWhite
71
- - bgDefault
58
+ - `bgBlack`
59
+ - `bgRed`
60
+ - `bgGreen`
61
+ - `bgYellow`
62
+ - `bgBlue`
63
+ - `bgMagenta`
64
+ - `bgCyan`
65
+ - `bgWhite`
66
+
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
+ ```
72
82
 
73
83
 
74
84
  ## License
75
85
 
76
- MIT License • © [Sindre Sorhus](http://sindresorhus.com)
86
+ MIT © [Sindre Sorhus](http://sindresorhus.com)
package/ansi-styles.js DELETED
@@ -1,31 +0,0 @@
1
- 'use strict';
2
- module.exports = {
3
- reset: '\x1b[0m',
4
- bold: '\x1b[1m',
5
- italic: '\x1b[3m',
6
- underline: '\x1b[4m',
7
- blink: '\x1b[5m',
8
- inverse: '\x1b[7m',
9
- strikethrough: '\x1b[9m',
10
-
11
- black: '\x1b[30m',
12
- red: '\x1b[31m',
13
- green: '\x1b[32m',
14
- yellow: '\x1b[33m',
15
- blue: '\x1b[34m',
16
- magenta: '\x1b[35m',
17
- cyan: '\x1b[36m',
18
- white: '\x1b[37m',
19
- default: '\x1b[39m',
20
- gray: '\x1B[90m',
21
-
22
- bgBlack: '\x1b[40m',
23
- bgRed: '\x1b[41m',
24
- bgGreen: '\x1b[42m',
25
- bgYellow: '\x1b[43m',
26
- bgBlue: '\x1b[44m',
27
- bgMagenta: '\x1b[45m',
28
- bgCyan: '\x1b[46m',
29
- bgWhite: '\x1b[47m',
30
- bgDefault: '\x1b[49m'
31
- };