ansi-styles 1.0.0 → 2.1.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,65 @@
1
+ 'use strict';
2
+
3
+ function assembleStyles () {
4
+ var styles = {
5
+ modifiers: {
6
+ reset: [0, 0],
7
+ bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
8
+ dim: [2, 22],
9
+ italic: [3, 23],
10
+ underline: [4, 24],
11
+ inverse: [7, 27],
12
+ hidden: [8, 28],
13
+ strikethrough: [9, 29]
14
+ },
15
+ colors: {
16
+ black: [30, 39],
17
+ red: [31, 39],
18
+ green: [32, 39],
19
+ yellow: [33, 39],
20
+ blue: [34, 39],
21
+ magenta: [35, 39],
22
+ cyan: [36, 39],
23
+ white: [37, 39],
24
+ gray: [90, 39]
25
+ },
26
+ bgColors: {
27
+ bgBlack: [40, 49],
28
+ bgRed: [41, 49],
29
+ bgGreen: [42, 49],
30
+ bgYellow: [43, 49],
31
+ bgBlue: [44, 49],
32
+ bgMagenta: [45, 49],
33
+ bgCyan: [46, 49],
34
+ bgWhite: [47, 49]
35
+ }
36
+ };
37
+
38
+ // fix humans
39
+ styles.colors.grey = styles.colors.gray;
40
+
41
+ Object.keys(styles).forEach(function (groupName) {
42
+ var group = styles[groupName];
43
+
44
+ Object.keys(group).forEach(function (styleName) {
45
+ var style = group[styleName];
46
+
47
+ styles[styleName] = group[styleName] = {
48
+ open: '\u001b[' + style[0] + 'm',
49
+ close: '\u001b[' + style[1] + 'm'
50
+ };
51
+ });
52
+
53
+ Object.defineProperty(styles, groupName, {
54
+ value: group,
55
+ enumerable: false
56
+ });
57
+ });
58
+
59
+ return styles;
60
+ }
61
+
62
+ Object.defineProperty(module, 'exports', {
63
+ enumerable: true,
64
+ get: assembleStyles
65
+ });
package/license ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/package.json CHANGED
@@ -1,7 +1,27 @@
1
1
  {
2
2
  "name": "ansi-styles",
3
- "version": "1.0.0",
4
- "description": "ANSI escape codes for colorizing strings in the terminal",
3
+ "version": "2.1.0",
4
+ "description": "ANSI escape codes for styling strings in the terminal",
5
+ "license": "MIT",
6
+ "repository": "chalk/ansi-styles",
7
+ "author": {
8
+ "name": "Sindre Sorhus",
9
+ "email": "sindresorhus@gmail.com",
10
+ "url": "sindresorhus.com"
11
+ },
12
+ "maintainers": [
13
+ "Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)",
14
+ "Joshua Appelman <jappelman@xebia.com> (jbnicolai.com)"
15
+ ],
16
+ "engines": {
17
+ "node": ">=0.10.0"
18
+ },
19
+ "scripts": {
20
+ "test": "mocha"
21
+ },
22
+ "files": [
23
+ "index.js"
24
+ ],
5
25
  "keywords": [
6
26
  "ansi",
7
27
  "styles",
@@ -24,29 +44,7 @@
24
44
  "command-line",
25
45
  "text"
26
46
  ],
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
47
  "devDependencies": {
47
- "mocha": "~1.12.0"
48
- },
49
- "engines": {
50
- "node": ">=0.8.0"
48
+ "mocha": "*"
51
49
  }
52
50
  }
package/readme.md CHANGED
@@ -1,18 +1,20 @@
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/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles)
2
2
 
3
- > [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) 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
- You probably want the higher-level [chalk](https://github.com/sindresorhus/chalk) module for styling your strings.
5
+ You probably want the higher-level [chalk](https://github.com/chalk/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`
12
+ ```
13
+ $ npm install --save ansi-styles
14
+ ```
13
15
 
14
16
 
15
- ## Example
17
+ ## Usage
16
18
 
17
19
  ```js
18
20
  var ansi = require('ansi-styles');
@@ -20,6 +22,7 @@ var ansi = require('ansi-styles');
20
22
  console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
21
23
  ```
22
24
 
25
+
23
26
  ## API
24
27
 
25
28
  Each style has an `open` and `close` property.
@@ -27,37 +30,55 @@ Each style has an `open` and `close` property.
27
30
 
28
31
  ## Styles
29
32
 
30
- ### General
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`
31
55
 
32
- - reset
33
- - bold
34
- - italic
35
- - underline
36
- - inverse
37
- - strikethrough
56
+ ### Background colors
38
57
 
39
- ### Text colors
58
+ - `bgBlack`
59
+ - `bgRed`
60
+ - `bgGreen`
61
+ - `bgYellow`
62
+ - `bgBlue`
63
+ - `bgMagenta`
64
+ - `bgCyan`
65
+ - `bgWhite`
40
66
 
41
- - black
42
- - red
43
- - green
44
- - yellow
45
- - blue
46
- - magenta
47
- - cyan
48
- - white
49
- - gray
50
67
 
51
- ### Background colors
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.
52
71
 
53
- - bgBlack
54
- - bgRed
55
- - bgGreen
56
- - bgYellow
57
- - bgBlue
58
- - bgMagenta
59
- - bgCyan
60
- - bgWhite
72
+ - `ansi.modifiers`
73
+ - `ansi.colors`
74
+ - `ansi.bgColors`
75
+
76
+
77
+ ###### Example
78
+
79
+ ```js
80
+ console.log(ansi.colors.green.open);
81
+ ```
61
82
 
62
83
 
63
84
  ## License
package/ansi-styles.js DELETED
@@ -1,38 +0,0 @@
1
- 'use strict';
2
- var styles = module.exports;
3
-
4
- var codes = {
5
- reset: [0, 0],
6
-
7
- bold: [1, 22],
8
- italic: [3, 23],
9
- underline: [4, 24],
10
- inverse: [7, 27],
11
- strikethrough: [9, 29],
12
-
13
- black: [30, 39],
14
- red: [31, 39],
15
- green: [32, 39],
16
- yellow: [33, 39],
17
- blue: [34, 39],
18
- magenta: [35, 39],
19
- cyan: [36, 39],
20
- white: [37, 39],
21
- gray: [90, 39],
22
-
23
- bgBlack: [40, 49],
24
- bgRed: [41, 49],
25
- bgGreen: [42, 49],
26
- bgYellow: [43, 49],
27
- bgBlue: [44, 49],
28
- bgMagenta: [45, 49],
29
- bgCyan: [46, 49],
30
- bgWhite: [47, 49]
31
- };
32
-
33
- Object.keys(codes).forEach(function (key) {
34
- var val = codes[key];
35
- var style = styles[key] = {};
36
- style.open = '\x1b[' + val[0] + 'm';
37
- style.close = '\x1b[' + val[1] + 'm';
38
- });