colors 1.2.1 → 1.2.5
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 +25 -25
- package/README.md +184 -184
- package/examples/normal-usage.js +81 -78
- package/examples/safe-string.js +77 -76
- package/index.d.ts +136 -134
- package/lib/colors.js +199 -179
- package/lib/custom/trap.js +46 -45
- package/lib/custom/zalgo.js +110 -104
- package/lib/extendStringPrototype.js +106 -113
- package/lib/index.js +13 -12
- package/lib/maps/america.js +12 -12
- package/lib/maps/rainbow.js +14 -13
- package/lib/maps/random.js +12 -8
- package/lib/maps/zebra.js +5 -5
- package/lib/styles.js +77 -77
- package/lib/system/has-flag.js +35 -23
- package/lib/system/supports-colors.js +151 -147
- package/package.json +39 -30
- package/safe.d.ts +48 -45
- package/safe.js +10 -9
- package/themes/generic-logging.js +12 -12
package/examples/safe-string.js
CHANGED
@@ -1,76 +1,77 @@
|
|
1
|
-
var colors = require('../safe');
|
2
|
-
|
3
|
-
console.log(colors.yellow(
|
4
|
-
|
5
|
-
console.log(colors.yellow.underline(
|
6
|
-
|
7
|
-
console.log(colors.red.bold(
|
8
|
-
|
9
|
-
console.log(colors.rainbow(
|
10
|
-
|
11
|
-
console.log(colors.trap(
|
12
|
-
|
13
|
-
console.log(colors.rainbow(colors.trap(
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
console.log(
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
console.log(colors.
|
28
|
-
|
29
|
-
console.log('
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
//
|
34
|
-
//
|
35
|
-
//
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
//
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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('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(colors.error('this is an error'));
|
53
|
+
|
54
|
+
// outputs yellow text
|
55
|
+
console.log(colors.warn('this is a warning'));
|
56
|
+
|
57
|
+
// outputs grey text
|
58
|
+
console.log(colors.input('this is an input'));
|
59
|
+
|
60
|
+
|
61
|
+
// console.log('Generic logging theme as file'.green.bold.underline);
|
62
|
+
|
63
|
+
// Load a theme from file
|
64
|
+
colors.setTheme(__dirname + '/../themes/generic-logging.js');
|
65
|
+
|
66
|
+
// outputs red text
|
67
|
+
console.log(colors.error('this is an error'));
|
68
|
+
|
69
|
+
// outputs yellow text
|
70
|
+
console.log(colors.warn('this is a warning'));
|
71
|
+
|
72
|
+
// outputs grey text
|
73
|
+
console.log(colors.input('this is an input'));
|
74
|
+
|
75
|
+
// console.log(colors.zalgo("Don't summon him"))
|
76
|
+
|
77
|
+
|
package/index.d.ts
CHANGED
@@ -1,134 +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
|
50
|
-
|
51
|
-
export
|
52
|
-
|
53
|
-
export
|
54
|
-
|
55
|
-
|
56
|
-
export const
|
57
|
-
|
58
|
-
export const
|
59
|
-
export const
|
60
|
-
export const
|
61
|
-
export const
|
62
|
-
export const
|
63
|
-
export const
|
64
|
-
export const
|
65
|
-
export const
|
66
|
-
|
67
|
-
export const
|
68
|
-
|
69
|
-
export const
|
70
|
-
export const
|
71
|
-
export const
|
72
|
-
export const
|
73
|
-
export const
|
74
|
-
export const
|
75
|
-
|
76
|
-
export const
|
77
|
-
|
78
|
-
export const
|
79
|
-
export const
|
80
|
-
export const
|
81
|
-
export const
|
82
|
-
export const
|
83
|
-
export const
|
84
|
-
|
85
|
-
export const
|
86
|
-
|
87
|
-
export const
|
88
|
-
export const
|
89
|
-
export const
|
90
|
-
export const
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
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
|
+
}
|