colors 1.1.1 → 1.2.1

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/LICENSE CHANGED
@@ -1,23 +1,25 @@
1
- Original Library
2
- - Copyright (c) Marak Squires
3
-
4
- Additional Functionality
5
- - Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in
15
- all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- THE SOFTWARE.
1
+ MIT License
2
+
3
+ Original Library
4
+ - Copyright (c) Marak Squires
5
+
6
+ Additional Functionality
7
+ - Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in
17
+ all copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
+ THE SOFTWARE.
@@ -1,177 +1,184 @@
1
- # colors.js [![Build Status](https://travis-ci.org/Marak/colors.js.svg?branch=master)](https://travis-ci.org/Marak/colors.js)
2
-
3
- ## get color and style in your node.js console
4
-
5
- ![Demo](https://raw.githubusercontent.com/Marak/colors.js/master/screenshots/colors.png)
6
-
7
- ## Installation
8
-
9
- npm install colors
10
-
11
- ## colors and styles!
12
-
13
- ### text colors
14
-
15
- - black
16
- - red
17
- - green
18
- - yellow
19
- - blue
20
- - magenta
21
- - cyan
22
- - white
23
- - gray
24
- - grey
25
-
26
- ### background colors
27
-
28
- - bgBlack
29
- - bgRed
30
- - bgGreen
31
- - bgYellow
32
- - bgBlue
33
- - bgMagenta
34
- - bgCyan
35
- - bgWhite
36
-
37
- ### styles
38
-
39
- - reset
40
- - bold
41
- - dim
42
- - italic
43
- - underline
44
- - inverse
45
- - hidden
46
- - strikethrough
47
-
48
- ### extras
49
-
50
- - rainbow
51
- - zebra
52
- - america
53
- - trap
54
- - random
55
-
56
-
57
- ## Usage
58
-
59
- By popular demand, `colors` now ships with two types of usages!
60
-
61
- The super nifty way
62
-
63
- ```js
64
- var colors = require('colors');
65
-
66
- console.log('hello'.green); // outputs green text
67
- console.log('i like cake and pies'.underline.red) // outputs red underlined text
68
- console.log('inverse the color'.inverse); // inverses the color
69
- console.log('OMG Rainbows!'.rainbow); // rainbow
70
- console.log('Run the trap'.trap); // Drops the bass
71
-
72
- ```
73
-
74
- or a slightly less nifty way which doesn't extend `String.prototype`
75
-
76
- ```js
77
- var colors = require('colors/safe');
78
-
79
- console.log(colors.green('hello')); // outputs green text
80
- console.log(colors.red.underline('i like cake and pies')) // outputs red underlined text
81
- console.log(colors.inverse('inverse the color')); // inverses the color
82
- console.log(colors.rainbow('OMG Rainbows!')); // rainbow
83
- console.log(colors.trap('Run the trap')); // Drops the bass
84
-
85
- ```
86
-
87
- I prefer the first way. Some people seem to be afraid of extending `String.prototype` and prefer the second way.
88
-
89
- If you are writing good code you will never have an issue with the first approach. If you really don't want to touch `String.prototype`, the second usage will not touch `String` native object.
90
-
91
- ## Disabling Colors
92
-
93
- To disable colors you can pass the following arguments in the command line to your application:
94
-
95
- ```bash
96
- node myapp.js --no-color
97
- ```
98
-
99
- ## Console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data)
100
-
101
- ```js
102
- var name = 'Marak';
103
- console.log(colors.green('Hello %s'), name);
104
- // outputs -> 'Hello Marak'
105
- ```
106
-
107
- ## Custom themes
108
-
109
- ### Using standard API
110
-
111
- ```js
112
-
113
- var colors = require('colors');
114
-
115
- colors.setTheme({
116
- silly: 'rainbow',
117
- input: 'grey',
118
- verbose: 'cyan',
119
- prompt: 'grey',
120
- info: 'green',
121
- data: 'grey',
122
- help: 'cyan',
123
- warn: 'yellow',
124
- debug: 'blue',
125
- error: 'red'
126
- });
127
-
128
- // outputs red text
129
- console.log("this is an error".error);
130
-
131
- // outputs yellow text
132
- console.log("this is a warning".warn);
133
- ```
134
-
135
- ### Using string safe API
136
-
137
- ```js
138
- var colors = require('colors/safe');
139
-
140
- // set single property
141
- var error = colors.red;
142
- error('this is red');
143
-
144
- // set theme
145
- colors.setTheme({
146
- silly: 'rainbow',
147
- input: 'grey',
148
- verbose: 'cyan',
149
- prompt: 'grey',
150
- info: 'green',
151
- data: 'grey',
152
- help: 'cyan',
153
- warn: 'yellow',
154
- debug: 'blue',
155
- error: 'red'
156
- });
157
-
158
- // outputs red text
159
- console.log(colors.error("this is an error"));
160
-
161
- // outputs yellow text
162
- console.log(colors.warn("this is a warning"));
163
-
164
- ```
165
-
166
- You can also combine them:
167
-
168
- ```javascript
169
- colors.setTheme({
170
- link: ['underline', 'blue']
171
- });
172
-
173
- // outputs underlined blue text
174
- console.log(colors.info('Listening on ') + colors.link('http://0.0.0.0:' + port));
175
- ```
176
-
177
- *Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.*
1
+ # colors.js
2
+ [![Build Status](https://travis-ci.org/Marak/colors.js.svg?branch=master)](https://travis-ci.org/Marak/colors.js)
3
+ [![version](https://img.shields.io/npm/v/colors.svg)](https://www.npmjs.org/package/colors)
4
+ [![dependencies](https://david-dm.org/Marak/colors.js.svg)](https://david-dm.org/Marak/colors.js)
5
+ [![devDependencies](https://david-dm.org/Marak/colors.js/dev-status.svg)](https://david-dm.org/Marak/colors.js#info=devDependencies)
6
+
7
+ Please check out the [roadmap](ROADMAP.md) for upcoming features and releases. Please open Issues to provide feedback, and check the `develop` branch for the latest bleeding-edge updates.
8
+
9
+ ## get color and style in your node.js console
10
+
11
+ ![Demo](https://raw.githubusercontent.com/Marak/colors.js/master/screenshots/colors.png)
12
+
13
+ ## Installation
14
+
15
+ npm install colors
16
+
17
+ ## colors and styles!
18
+
19
+ ### text colors
20
+
21
+ - black
22
+ - red
23
+ - green
24
+ - yellow
25
+ - blue
26
+ - magenta
27
+ - cyan
28
+ - white
29
+ - gray
30
+ - grey
31
+
32
+ ### background colors
33
+
34
+ - bgBlack
35
+ - bgRed
36
+ - bgGreen
37
+ - bgYellow
38
+ - bgBlue
39
+ - bgMagenta
40
+ - bgCyan
41
+ - bgWhite
42
+
43
+ ### styles
44
+
45
+ - reset
46
+ - bold
47
+ - dim
48
+ - italic
49
+ - underline
50
+ - inverse
51
+ - hidden
52
+ - strikethrough
53
+
54
+ ### extras
55
+
56
+ - rainbow
57
+ - zebra
58
+ - america
59
+ - trap
60
+ - random
61
+
62
+
63
+ ## Usage
64
+
65
+ By popular demand, `colors` now ships with two types of usages!
66
+
67
+ The super nifty way
68
+
69
+ ```js
70
+ var colors = require('colors');
71
+
72
+ console.log('hello'.green); // outputs green text
73
+ console.log('i like cake and pies'.underline.red) // outputs red underlined text
74
+ console.log('inverse the color'.inverse); // inverses the color
75
+ console.log('OMG Rainbows!'.rainbow); // rainbow
76
+ console.log('Run the trap'.trap); // Drops the bass
77
+
78
+ ```
79
+
80
+ or a slightly less nifty way which doesn't extend `String.prototype`
81
+
82
+ ```js
83
+ var colors = require('colors/safe');
84
+
85
+ console.log(colors.green('hello')); // outputs green text
86
+ console.log(colors.red.underline('i like cake and pies')) // outputs red underlined text
87
+ console.log(colors.inverse('inverse the color')); // inverses the color
88
+ console.log(colors.rainbow('OMG Rainbows!')); // rainbow
89
+ console.log(colors.trap('Run the trap')); // Drops the bass
90
+
91
+ ```
92
+
93
+ I prefer the first way. Some people seem to be afraid of extending `String.prototype` and prefer the second way.
94
+
95
+ If you are writing good code you will never have an issue with the first approach. If you really don't want to touch `String.prototype`, the second usage will not touch `String` native object.
96
+
97
+ ## Disabling Colors
98
+
99
+ To disable colors you can pass the following arguments in the command line to your application:
100
+
101
+ ```bash
102
+ node myapp.js --no-color
103
+ ```
104
+
105
+ ## Console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data)
106
+
107
+ ```js
108
+ var name = 'Marak';
109
+ console.log(colors.green('Hello %s'), name);
110
+ // outputs -> 'Hello Marak'
111
+ ```
112
+
113
+ ## Custom themes
114
+
115
+ ### Using standard API
116
+
117
+ ```js
118
+
119
+ var colors = require('colors');
120
+
121
+ colors.setTheme({
122
+ silly: 'rainbow',
123
+ input: 'grey',
124
+ verbose: 'cyan',
125
+ prompt: 'grey',
126
+ info: 'green',
127
+ data: 'grey',
128
+ help: 'cyan',
129
+ warn: 'yellow',
130
+ debug: 'blue',
131
+ error: 'red'
132
+ });
133
+
134
+ // outputs red text
135
+ console.log("this is an error".error);
136
+
137
+ // outputs yellow text
138
+ console.log("this is a warning".warn);
139
+ ```
140
+
141
+ ### Using string safe API
142
+
143
+ ```js
144
+ var colors = require('colors/safe');
145
+
146
+ // set single property
147
+ var error = colors.red;
148
+ error('this is red');
149
+
150
+ // set theme
151
+ colors.setTheme({
152
+ silly: 'rainbow',
153
+ input: 'grey',
154
+ verbose: 'cyan',
155
+ prompt: 'grey',
156
+ info: 'green',
157
+ data: 'grey',
158
+ help: 'cyan',
159
+ warn: 'yellow',
160
+ debug: 'blue',
161
+ error: 'red'
162
+ });
163
+
164
+ // outputs red text
165
+ console.log(colors.error("this is an error"));
166
+
167
+ // outputs yellow text
168
+ console.log(colors.warn("this is a warning"));
169
+
170
+ ```
171
+
172
+ ### Combining Colors
173
+
174
+ ```javascript
175
+ var colors = require('colors');
176
+
177
+ colors.setTheme({
178
+ custom: ['red', 'underline']
179
+ });
180
+
181
+ console.log('test'.custom);
182
+ ```
183
+
184
+ *Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.*
@@ -1,74 +1,78 @@
1
- var colors = require('../lib/index');
2
-
3
- console.log("First some yellow text".yellow);
4
-
5
- console.log("Underline that text".yellow.underline);
6
-
7
- console.log("Make it bold and red".red.bold);
8
-
9
- console.log(("Double Raindows All Day Long").rainbow)
10
-
11
- console.log("Drop the bass".trap)
12
-
13
- console.log("DROP THE RAINBOW BASS".trap.rainbow)
14
-
15
-
16
- console.log('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
17
-
18
- console.log('So '.green + 'are'.underline + ' ' + 'inverse'.inverse + ' styles! '.yellow.bold); // styles not widely supported
19
- console.log("Zebras are so fun!".zebra);
20
-
21
- //
22
- // Remark: .strikethrough may not work with Mac OS Terminal App
23
- //
24
- console.log("This is " + "not".strikethrough + " fun.");
25
-
26
- console.log('Background color attack!'.black.bgWhite)
27
- console.log('Use random styles on everything!'.random)
28
- console.log('America, Heck Yeah!'.america)
29
-
30
-
31
- console.log('Setting themes is useful')
32
-
33
- //
34
- // Custom themes
35
- //
36
- console.log('Generic logging theme as JSON'.green.bold.underline);
37
- // Load theme with JSON literal
38
- colors.setTheme({
39
- silly: 'rainbow',
40
- input: 'grey',
41
- verbose: 'cyan',
42
- prompt: 'grey',
43
- info: 'green',
44
- data: 'grey',
45
- help: 'cyan',
46
- warn: 'yellow',
47
- debug: 'blue',
48
- error: 'red'
49
- });
50
-
51
- // outputs red text
52
- console.log("this is an error".error);
53
-
54
- // outputs yellow text
55
- console.log("this is a warning".warn);
56
-
57
- // outputs grey text
58
- console.log("this is an input".input);
59
-
60
- console.log('Generic logging theme as file'.green.bold.underline);
61
-
62
- // Load a theme from file
63
- colors.setTheme(__dirname + '/../themes/generic-logging.js');
64
-
65
- // outputs red text
66
- console.log("this is an error".error);
67
-
68
- // outputs yellow text
69
- console.log("this is a warning".warn);
70
-
71
- // outputs grey text
72
- console.log("this is an input".input);
73
-
1
+ var colors = require('../lib/index');
2
+
3
+ console.log("First some yellow text".yellow);
4
+
5
+ console.log("Underline that text".yellow.underline);
6
+
7
+ console.log("Make it bold and red".red.bold);
8
+
9
+ console.log(("Double Raindows All Day Long").rainbow)
10
+
11
+ console.log("Drop the bass".trap)
12
+
13
+ console.log("DROP THE RAINBOW BASS".trap.rainbow)
14
+
15
+
16
+ console.log('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
17
+
18
+ console.log('So '.green + 'are'.underline + ' ' + 'inverse'.inverse + ' styles! '.yellow.bold); // styles not widely supported
19
+ console.log("Zebras are so fun!".zebra);
20
+
21
+ //
22
+ // Remark: .strikethrough may not work with Mac OS Terminal App
23
+ //
24
+ console.log("This is " + "not".strikethrough + " fun.");
25
+
26
+ console.log('Background color attack!'.black.bgWhite)
27
+ console.log('Use random styles on everything!'.random)
28
+ console.log('America, Heck Yeah!'.america)
29
+
30
+
31
+ console.log('Setting themes is useful')
32
+
33
+ //
34
+ // Custom themes
35
+ //
36
+ console.log('Generic logging theme as JSON'.green.bold.underline);
37
+ // Load theme with JSON literal
38
+ colors.setTheme({
39
+ silly: 'rainbow',
40
+ input: 'grey',
41
+ verbose: 'cyan',
42
+ prompt: 'grey',
43
+ info: 'green',
44
+ data: 'grey',
45
+ help: 'cyan',
46
+ warn: 'yellow',
47
+ debug: 'blue',
48
+ error: 'red'
49
+ });
50
+
51
+ // outputs red text
52
+ console.log("this is an error".error);
53
+
54
+ // outputs yellow text
55
+ console.log("this is a warning".warn);
56
+
57
+ // outputs grey text
58
+ console.log("this is an input".input);
59
+
60
+ console.log('Generic logging theme as file'.green.bold.underline);
61
+
62
+ // Load a theme from file
63
+ try {
64
+ colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));
65
+ } catch (err) {
66
+ console.log(err);
67
+ }
68
+
69
+ // outputs red text
70
+ console.log("this is an error".error);
71
+
72
+ // outputs yellow text
73
+ console.log("this is a warning".warn);
74
+
75
+ // outputs grey text
76
+ console.log("this is an input".input);
77
+
74
78
  //console.log("Don't summon".zalgo)