colors-fix 1.4.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of colors-fix might be problematic. Click here for more details.

package/LICENSE ADDED
@@ -0,0 +1,25 @@
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.
package/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # colors-dev
2
+ ## get color and style in your node.js console
3
+
4
+ ![Demo](https://raw.githubusercontent.com/Marak/colors.js/master/screenshots/colors.png)
5
+
6
+ ## Installation
7
+
8
+ npm install colors-dev
9
+
10
+ ## colors and styles!
11
+
12
+ ### text colors
13
+
14
+ - black
15
+ - red
16
+ - green
17
+ - yellow
18
+ - blue
19
+ - magenta
20
+ - cyan
21
+ - white
22
+ - gray
23
+ - grey
24
+
25
+ ### bright text colors
26
+
27
+ - brightRed
28
+ - brightGreen
29
+ - brightYellow
30
+ - brightBlue
31
+ - brightMagenta
32
+ - brightCyan
33
+ - brightWhite
34
+
35
+ ### background colors
36
+
37
+ - bgBlack
38
+ - bgRed
39
+ - bgGreen
40
+ - bgYellow
41
+ - bgBlue
42
+ - bgMagenta
43
+ - bgCyan
44
+ - bgWhite
45
+ - bgGray
46
+ - bgGrey
47
+
48
+ ### bright background colors
49
+
50
+ - bgBrightRed
51
+ - bgBrightGreen
52
+ - bgBrightYellow
53
+ - bgBrightBlue
54
+ - bgBrightMagenta
55
+ - bgBrightCyan
56
+ - bgBrightWhite
57
+
58
+ ### styles
59
+
60
+ - reset
61
+ - bold
62
+ - dim
63
+ - italic
64
+ - underline
65
+ - inverse
66
+ - hidden
67
+ - strikethrough
68
+
69
+ ### extras
70
+
71
+ - rainbow
72
+ - zebra
73
+ - america
74
+ - trap
75
+ - random
76
+
77
+
78
+ ## Usage
79
+
80
+ By popular demand, `colors-dev` now ships with two types of usages!
81
+
82
+ The super nifty way
83
+
84
+ ```js
85
+ var colors = require('colors-dev');
86
+
87
+ console.log('hello'.green); // outputs green text
88
+ console.log('i like cake and pies'.underline.red); // outputs red underlined text
89
+ console.log('inverse the color'.inverse); // inverses the color
90
+ console.log('OMG Rainbows!'.rainbow); // rainbow
91
+ console.log('Run the trap'.trap); // Drops the bass
92
+
93
+ ```
94
+
95
+ or a slightly less nifty way which doesn't extend `String.prototype`
96
+
97
+ ```js
98
+ var colors = require('colors-dev/safe');
99
+
100
+ console.log(colors.green('hello')); // outputs green text
101
+ console.log(colors.red.underline('i like cake and pies')); // outputs red underlined text
102
+ console.log(colors.inverse('inverse the color')); // inverses the color
103
+ console.log(colors.rainbow('OMG Rainbows!')); // rainbow
104
+ console.log(colors.trap('Run the trap')); // Drops the bass
105
+
106
+ ```
107
+
108
+ I prefer the first way. Some people seem to be afraid of extending `String.prototype` and prefer the second way.
109
+
110
+ 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.
111
+
112
+ ## Enabling/Disabling Colors
113
+
114
+ The package will auto-detect whether your terminal can use colors and enable/disable accordingly. When colors are disabled, the color functions do nothing. You can override this with a command-line flag:
115
+
116
+ ```bash
117
+ node myapp.js --no-color
118
+ node myapp.js --color=false
119
+
120
+ node myapp.js --color
121
+ node myapp.js --color=true
122
+ node myapp.js --color=always
123
+
124
+ FORCE_COLOR=1 node myapp.js
125
+ ```
126
+
127
+ Or in code:
128
+
129
+ ```javascript
130
+ var colors = require('colors-dev');
131
+ colors.enable();
132
+ colors.disable();
133
+ ```
134
+
135
+ ## Console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data)
136
+
137
+ ```js
138
+ var name = 'fuhrer';
139
+ console.log(colors.green('Hello %s'), name);
140
+ // outputs -> 'Hello fuhrer'
141
+ ```
142
+
143
+ ## Custom themes
144
+
145
+ ### Using standard API
146
+
147
+ ```js
148
+
149
+ var colors = require('colors-dev');
150
+
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("this is an error".error);
166
+
167
+ // outputs yellow text
168
+ console.log("this is a warning".warn);
169
+ ```
170
+
171
+ ### Using string safe API
172
+
173
+ ```js
174
+ var colors = require('colors-dev/safe');
175
+
176
+ // set single property
177
+ var error = colors.red;
178
+ error('this is red');
179
+
180
+ // set theme
181
+ colors.setTheme({
182
+ silly: 'rainbow',
183
+ input: 'grey',
184
+ verbose: 'cyan',
185
+ prompt: 'grey',
186
+ info: 'green',
187
+ data: 'grey',
188
+ help: 'cyan',
189
+ warn: 'yellow',
190
+ debug: 'blue',
191
+ error: 'red'
192
+ });
193
+
194
+ // outputs red text
195
+ console.log(colors.error("this is an error"));
196
+
197
+ // outputs yellow text
198
+ console.log(colors.warn("this is a warning"));
199
+
200
+ ```
201
+
202
+ ### Combining Colors
203
+
204
+ ```javascript
205
+ var colors = require('colors-dev');
206
+
207
+ colors.setTheme({
208
+ custom: ['red', 'underline']
209
+ });
210
+
211
+ console.log('test'.custom);
212
+ ```
213
+
214
+ *Protip: There is a secret undocumented style in `colors-dev`. If you find the style you can summon him.*
@@ -0,0 +1,82 @@
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
+ // styles not widely supported
16
+ console.log('Chains are also cool.'.bold.italic.underline.red);
17
+
18
+ // styles not widely supported
19
+ console.log('So '.green + 'are'.underline + ' ' + 'inverse'.inverse
20
+ + ' styles! '.yellow.bold);
21
+ console.log('Zebras are so fun!'.zebra);
22
+
23
+ //
24
+ // Remark: .strikethrough may not work with Mac OS Terminal App
25
+ //
26
+ console.log('This is ' + 'not'.strikethrough + ' fun.');
27
+
28
+ console.log('Background color attack!'.black.bgWhite);
29
+ console.log('Use random styles on everything!'.random);
30
+ console.log('America, Heck Yeah!'.america);
31
+
32
+ console.log('Blindingly '.brightCyan + 'bright? '.brightRed + 'Why '.brightYellow + 'not?!'.brightGreen);
33
+
34
+ console.log('Setting themes is useful');
35
+
36
+ //
37
+ // Custom themes
38
+ //
39
+ console.log('Generic logging theme as JSON'.green.bold.underline);
40
+ // Load theme with JSON literal
41
+ colors.setTheme({
42
+ silly: 'rainbow',
43
+ input: 'grey',
44
+ verbose: 'cyan',
45
+ prompt: 'grey',
46
+ info: 'green',
47
+ data: 'grey',
48
+ help: 'cyan',
49
+ warn: 'yellow',
50
+ debug: 'blue',
51
+ error: 'red',
52
+ });
53
+
54
+ // outputs red text
55
+ console.log('this is an error'.error);
56
+
57
+ // outputs yellow text
58
+ console.log('this is a warning'.warn);
59
+
60
+ // outputs grey text
61
+ console.log('this is an input'.input);
62
+
63
+ console.log('Generic logging theme as file'.green.bold.underline);
64
+
65
+ // Load a theme from file
66
+ try {
67
+ colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));
68
+ } catch (err) {
69
+ console.log(err);
70
+ }
71
+
72
+ // outputs red text
73
+ console.log('this is an error'.error);
74
+
75
+ // outputs yellow text
76
+ console.log('this is a warning'.warn);
77
+
78
+ // outputs grey text
79
+ console.log('this is an input'.input);
80
+
81
+ // console.log("Don't summon".zalgo)
82
+
@@ -0,0 +1,79 @@
1
+ var colors = require('../safe');
2
+
3
+ console.log(colors.yellow('First some yellow text'));
4
+
5
+ console.log(colors.yellow.underline('Underline that text'));
6
+
7
+ console.log(colors.red.bold('Make it bold and red'));
8
+
9
+ console.log(colors.rainbow('Double Raindows All Day Long'));
10
+
11
+ console.log(colors.trap('Drop the bass'));
12
+
13
+ console.log(colors.rainbow(colors.trap('DROP THE RAINBOW BASS')));
14
+
15
+ // styles not widely supported
16
+ console.log(colors.bold.italic.underline.red('Chains are also cool.'));
17
+
18
+ // styles not widely supported
19
+ console.log(colors.green('So ') + colors.underline('are') + ' '
20
+ + colors.inverse('inverse') + colors.yellow.bold(' styles! '));
21
+
22
+ console.log(colors.zebra('Zebras are so fun!'));
23
+
24
+ console.log('This is ' + colors.strikethrough('not') + ' fun.');
25
+
26
+
27
+ console.log(colors.black.bgWhite('Background color attack!'));
28
+ console.log(colors.random('Use random styles on everything!'));
29
+ console.log(colors.america('America, Heck Yeah!'));
30
+
31
+ console.log(colors.brightCyan('Blindingly ') + colors.brightRed('bright? ') + colors.brightYellow('Why ') + colors.brightGreen('not?!'));
32
+
33
+ console.log('Setting themes is useful');
34
+
35
+ //
36
+ // Custom themes
37
+ //
38
+ // console.log('Generic logging theme as JSON'.green.bold.underline);
39
+ // Load theme with JSON literal
40
+ colors.setTheme({
41
+ silly: 'rainbow',
42
+ input: 'blue',
43
+ verbose: 'cyan',
44
+ prompt: 'grey',
45
+ info: 'green',
46
+ data: 'grey',
47
+ help: 'cyan',
48
+ warn: 'yellow',
49
+ debug: 'blue',
50
+ error: 'red',
51
+ });
52
+
53
+ // outputs red text
54
+ console.log(colors.error('this is an error'));
55
+
56
+ // outputs yellow text
57
+ console.log(colors.warn('this is a warning'));
58
+
59
+ // outputs blue text
60
+ console.log(colors.input('this is an input'));
61
+
62
+
63
+ // console.log('Generic logging theme as file'.green.bold.underline);
64
+
65
+ // Load a theme from file
66
+ colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));
67
+
68
+ // outputs red text
69
+ console.log(colors.error('this is an error'));
70
+
71
+ // outputs yellow text
72
+ console.log(colors.warn('this is a warning'));
73
+
74
+ // outputs grey text
75
+ console.log(colors.input('this is an input'));
76
+
77
+ // console.log(colors.zalgo("Don't summon him"))
78
+
79
+
package/index.d.ts ADDED
@@ -0,0 +1,136 @@
1
+ // Type definitions for Colors.js 1.2
2
+ // Project: https://github.com/Marak/colors.js
3
+ // Definitions by: Bart van der Schoor <https://github.com/Bartvds>, Staffan Eketorp <https://github.com/staeke>
4
+ // Definitions: https://github.com/Marak/colors.js
5
+
6
+ export interface Color {
7
+ (text: string): string;
8
+
9
+ strip: Color;
10
+ stripColors: Color;
11
+
12
+ black: Color;
13
+ red: Color;
14
+ green: Color;
15
+ yellow: Color;
16
+ blue: Color;
17
+ magenta: Color;
18
+ cyan: Color;
19
+ white: Color;
20
+ gray: Color;
21
+ grey: Color;
22
+
23
+ bgBlack: Color;
24
+ bgRed: Color;
25
+ bgGreen: Color;
26
+ bgYellow: Color;
27
+ bgBlue: Color;
28
+ bgMagenta: Color;
29
+ bgCyan: Color;
30
+ bgWhite: Color;
31
+
32
+ reset: Color;
33
+ bold: Color;
34
+ dim: Color;
35
+ italic: Color;
36
+ underline: Color;
37
+ inverse: Color;
38
+ hidden: Color;
39
+ strikethrough: Color;
40
+
41
+ rainbow: Color;
42
+ zebra: Color;
43
+ america: Color;
44
+ trap: Color;
45
+ random: Color;
46
+ zalgo: Color;
47
+ }
48
+
49
+ export function enable(): void;
50
+ export function disable(): void;
51
+ export function setTheme(theme: any): void;
52
+
53
+ export let enabled: boolean;
54
+
55
+ export const strip: Color;
56
+ export const stripColors: Color;
57
+
58
+ export const black: Color;
59
+ export const red: Color;
60
+ export const green: Color;
61
+ export const yellow: Color;
62
+ export const blue: Color;
63
+ export const magenta: Color;
64
+ export const cyan: Color;
65
+ export const white: Color;
66
+ export const gray: Color;
67
+ export const grey: Color;
68
+
69
+ export const bgBlack: Color;
70
+ export const bgRed: Color;
71
+ export const bgGreen: Color;
72
+ export const bgYellow: Color;
73
+ export const bgBlue: Color;
74
+ export const bgMagenta: Color;
75
+ export const bgCyan: Color;
76
+ export const bgWhite: Color;
77
+
78
+ export const reset: Color;
79
+ export const bold: Color;
80
+ export const dim: Color;
81
+ export const italic: Color;
82
+ export const underline: Color;
83
+ export const inverse: Color;
84
+ export const hidden: Color;
85
+ export const strikethrough: Color;
86
+
87
+ export const rainbow: Color;
88
+ export const zebra: Color;
89
+ export const america: Color;
90
+ export const trap: Color;
91
+ export const random: Color;
92
+ export const zalgo: Color;
93
+
94
+ declare global {
95
+ interface String {
96
+ strip: string;
97
+ stripColors: string;
98
+
99
+ black: string;
100
+ red: string;
101
+ green: string;
102
+ yellow: string;
103
+ blue: string;
104
+ magenta: string;
105
+ cyan: string;
106
+ white: string;
107
+ gray: string;
108
+ grey: string;
109
+
110
+ bgBlack: string;
111
+ bgRed: string;
112
+ bgGreen: string;
113
+ bgYellow: string;
114
+ bgBlue: string;
115
+ bgMagenta: string;
116
+ bgCyan: string;
117
+ bgWhite: string;
118
+
119
+ reset: string;
120
+ // @ts-ignore
121
+ bold: string;
122
+ dim: string;
123
+ italic: string;
124
+ underline: string;
125
+ inverse: string;
126
+ hidden: string;
127
+ strikethrough: string;
128
+
129
+ rainbow: string;
130
+ zebra: string;
131
+ america: string;
132
+ trap: string;
133
+ random: string;
134
+ zalgo: string;
135
+ }
136
+ }