ansi-styles 0.1.0 → 1.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.
Files changed (3) hide show
  1. package/ansi-styles.js +34 -27
  2. package/package.json +15 -12
  3. package/readme.md +8 -17
package/ansi-styles.js CHANGED
@@ -1,31 +1,38 @@
1
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',
2
+ var styles = module.exports;
10
3
 
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',
4
+ var codes = {
5
+ reset: [0, 0],
21
6
 
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'
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
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
+ });
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "ansi-styles",
3
- "version": "0.1.0",
3
+ "version": "1.0.0",
4
4
  "description": "ANSI escape codes for colorizing strings in the terminal",
5
5
  "keywords": [
6
6
  "ansi",
7
7
  "styles",
8
8
  "color",
9
+ "colour",
9
10
  "colors",
10
11
  "terminal",
11
12
  "console",
@@ -15,16 +16,26 @@
15
16
  "escape",
16
17
  "formatting",
17
18
  "rgb",
18
- "256"
19
+ "256",
20
+ "shell",
21
+ "xterm",
22
+ "log",
23
+ "logging",
24
+ "command-line",
25
+ "text"
19
26
  ],
20
27
  "homepage": "https://github.com/sindresorhus/ansi-styles",
21
28
  "bugs": "https://github.com/sindresorhus/ansi-styles/issues",
29
+ "license": "MIT",
22
30
  "author": {
23
31
  "name": "Sindre Sorhus",
24
32
  "email": "sindresorhus@gmail.com",
25
33
  "url": "http://sindresorhus.com"
26
34
  },
27
- "main": "ansi-styles.js",
35
+ "files": [
36
+ "ansi-styles.js"
37
+ ],
38
+ "main": "ansi-styles",
28
39
  "repository": {
29
40
  "type": "git",
30
41
  "url": "git://github.com/sindresorhus/ansi-styles.git"
@@ -37,13 +48,5 @@
37
48
  },
38
49
  "engines": {
39
50
  "node": ">=0.8.0"
40
- },
41
- "licenses": [
42
- {
43
- "type": "MIT"
44
- }
45
- ],
46
- "files": [
47
- "ansi-styles.js"
48
- ]
51
+ }
49
52
  }
package/readme.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # ansi-styles [![Build Status](https://secure.travis-ci.org/sindresorhus/ansi-styles.png?branch=master)](http://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 colorizing strings in the terminal.
4
+
5
+ You probably want the higher-level [chalk](https://github.com/sindresorhus/chalk) module for styling your strings.
4
6
 
5
7
  ![screenshot](screenshot.png)
6
8
 
@@ -12,23 +14,15 @@ Install with [npm](https://npmjs.org/package/ansi-styles): `npm install --save a
12
14
 
13
15
  ## Example
14
16
 
15
- Generates the above screenshot.
16
-
17
17
  ```js
18
18
  var ansi = require('ansi-styles');
19
19
 
20
- console.log(ansi.green + 'Styles:' + ansi.reset + '\n');
21
-
22
- Object.keys(ansi).forEach(function (el) {
23
- var style = ansi[el];
20
+ console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
21
+ ```
24
22
 
25
- if (/^bg[^B]/.test(el)) {
26
- style = ansi.black + style;
27
- }
23
+ ## API
28
24
 
29
- process.stdout.write(style + el + ansi.reset + ' ');
30
- });
31
- ```
25
+ Each style has an `open` and `close` property.
32
26
 
33
27
 
34
28
  ## Styles
@@ -39,7 +33,6 @@ Object.keys(ansi).forEach(function (el) {
39
33
  - bold
40
34
  - italic
41
35
  - underline
42
- - blink
43
36
  - inverse
44
37
  - strikethrough
45
38
 
@@ -53,7 +46,6 @@ Object.keys(ansi).forEach(function (el) {
53
46
  - magenta
54
47
  - cyan
55
48
  - white
56
- - default
57
49
  - gray
58
50
 
59
51
  ### Background colors
@@ -66,9 +58,8 @@ Object.keys(ansi).forEach(function (el) {
66
58
  - bgMagenta
67
59
  - bgCyan
68
60
  - bgWhite
69
- - bgDefault
70
61
 
71
62
 
72
63
  ## License
73
64
 
74
- MIT License • © [Sindre Sorhus](http://sindresorhus.com)
65
+ MIT © [Sindre Sorhus](http://sindresorhus.com)