ansi-styles 0.2.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.
package/ansi-styles.js CHANGED
@@ -1,29 +1,38 @@
1
1
  'use strict';
2
- module.exports = {
3
- reset: ['\x1b[0m', '\x1b[0m'],
2
+ var styles = module.exports;
4
3
 
5
- bold: ['\x1b[1m', '\x1b[22m'],
6
- italic: ['\x1b[3m', '\x1b[23m'],
7
- underline: ['\x1b[4m', '\x1b[24m'],
8
- inverse: ['\x1b[7m', '\x1b[27m'],
9
- strikethrough: ['\x1b[9m', '\x1b[29m'],
4
+ var codes = {
5
+ reset: [0, 0],
10
6
 
11
- black: ['\x1b[30m', '\x1b[39m'],
12
- red: ['\x1b[31m', '\x1b[39m'],
13
- green: ['\x1b[32m', '\x1b[39m'],
14
- yellow: ['\x1b[33m', '\x1b[39m'],
15
- blue: ['\x1b[34m', '\x1b[39m'],
16
- magenta: ['\x1b[35m', '\x1b[39m'],
17
- cyan: ['\x1b[36m', '\x1b[39m'],
18
- white: ['\x1b[37m', '\x1b[39m'],
19
- gray: ['\x1B[90m', '\x1b[39m'],
7
+ bold: [1, 22],
8
+ italic: [3, 23],
9
+ underline: [4, 24],
10
+ inverse: [7, 27],
11
+ strikethrough: [9, 29],
20
12
 
21
- bgBlack: ['\x1b[40m', '\x1b[49m'],
22
- bgRed: ['\x1b[41m', '\x1b[49m'],
23
- bgGreen: ['\x1b[42m', '\x1b[49m'],
24
- bgYellow: ['\x1b[43m', '\x1b[49m'],
25
- bgBlue: ['\x1b[44m', '\x1b[49m'],
26
- bgMagenta: ['\x1b[45m', '\x1b[49m'],
27
- bgCyan: ['\x1b[46m', '\x1b[49m'],
28
- bgWhite: ['\x1b[47m', '\x1b[49m']
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]
29
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,6 +1,6 @@
1
1
  {
2
2
  "name": "ansi-styles",
3
- "version": "0.2.0",
3
+ "version": "1.0.0",
4
4
  "description": "ANSI escape codes for colorizing strings in the terminal",
5
5
  "keywords": [
6
6
  "ansi",
package/readme.md CHANGED
@@ -1,6 +1,6 @@
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
4
 
5
5
  You probably want the higher-level [chalk](https://github.com/sindresorhus/chalk) module for styling your strings.
6
6
 
@@ -17,12 +17,12 @@ Install with [npm](https://npmjs.org/package/ansi-styles): `npm install --save a
17
17
  ```js
18
18
  var ansi = require('ansi-styles');
19
19
 
20
- console.log(ansi.green[0] + 'Hello world!' + ansi.green[1]);
20
+ console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
21
21
  ```
22
22
 
23
23
  ## API
24
24
 
25
- Each style is an array of a start and end escape code.
25
+ Each style has an `open` and `close` property.
26
26
 
27
27
 
28
28
  ## Styles
@@ -62,4 +62,4 @@ Each style is an array of a start and end escape code.
62
62
 
63
63
  ## License
64
64
 
65
- MIT License • © [Sindre Sorhus](http://sindresorhus.com)
65
+ MIT © [Sindre Sorhus](http://sindresorhus.com)