colors 1.2.5 → 1.3.3
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/examples/safe-string.js +3 -3
- package/index.d.ts +2 -2
- package/lib/colors.js +7 -5
- package/lib/custom/trap.js +2 -2
- package/lib/custom/zalgo.js +15 -15
- package/lib/extendStringPrototype.js +16 -12
- package/lib/maps/america.js +2 -4
- package/lib/maps/rainbow.js +2 -4
- package/lib/maps/random.js +3 -5
- package/lib/maps/zebra.js +4 -4
- package/package.json +9 -3
package/examples/safe-string.js
CHANGED
@@ -37,7 +37,7 @@ console.log('Setting themes is useful');
|
|
37
37
|
// Load theme with JSON literal
|
38
38
|
colors.setTheme({
|
39
39
|
silly: 'rainbow',
|
40
|
-
input: '
|
40
|
+
input: 'blue',
|
41
41
|
verbose: 'cyan',
|
42
42
|
prompt: 'grey',
|
43
43
|
info: 'green',
|
@@ -54,14 +54,14 @@ console.log(colors.error('this is an error'));
|
|
54
54
|
// outputs yellow text
|
55
55
|
console.log(colors.warn('this is a warning'));
|
56
56
|
|
57
|
-
// outputs
|
57
|
+
// outputs blue text
|
58
58
|
console.log(colors.input('this is an input'));
|
59
59
|
|
60
60
|
|
61
61
|
// console.log('Generic logging theme as file'.green.bold.underline);
|
62
62
|
|
63
63
|
// Load a theme from file
|
64
|
-
colors.setTheme(__dirname + '/../themes/generic-logging.js');
|
64
|
+
colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));
|
65
65
|
|
66
66
|
// outputs red text
|
67
67
|
console.log(colors.error('this is an error'));
|
package/index.d.ts
CHANGED
package/lib/colors.js
CHANGED
@@ -125,7 +125,9 @@ function applyStyle() {
|
|
125
125
|
var code = ansiStyles[nestedStyles[i]];
|
126
126
|
str = code.open + str.replace(code.closeRe, code.open) + code.close;
|
127
127
|
if (newLinesPresent) {
|
128
|
-
str = str.replace(newLineRegex,
|
128
|
+
str = str.replace(newLineRegex, function(match) {
|
129
|
+
return code.close + match + code.open;
|
130
|
+
});
|
129
131
|
}
|
130
132
|
}
|
131
133
|
|
@@ -183,10 +185,10 @@ colors.zalgo = require('./custom/zalgo');
|
|
183
185
|
|
184
186
|
// maps
|
185
187
|
colors.maps = {};
|
186
|
-
colors.maps.america = require('./maps/america');
|
187
|
-
colors.maps.zebra = require('./maps/zebra');
|
188
|
-
colors.maps.rainbow = require('./maps/rainbow');
|
189
|
-
colors.maps.random = require('./maps/random');
|
188
|
+
colors.maps.america = require('./maps/america')(colors);
|
189
|
+
colors.maps.zebra = require('./maps/zebra')(colors);
|
190
|
+
colors.maps.rainbow = require('./maps/rainbow')(colors);
|
191
|
+
colors.maps.random = require('./maps/random')(colors);
|
190
192
|
|
191
193
|
for (var map in colors.maps) {
|
192
194
|
(function(map) {
|
package/lib/custom/trap.js
CHANGED
@@ -8,7 +8,7 @@ module['exports'] = function runTheTrap(text, options) {
|
|
8
8
|
c: ['\u00a9', '\u023b', '\u03fe'],
|
9
9
|
d: ['\u00d0', '\u018a', '\u0500', '\u0501', '\u0502', '\u0503'],
|
10
10
|
e: ['\u00cb', '\u0115', '\u018e', '\u0258', '\u03a3', '\u03be', '\u04bc',
|
11
|
-
|
11
|
+
'\u0a6c'],
|
12
12
|
f: ['\u04fa'],
|
13
13
|
g: ['\u0262'],
|
14
14
|
h: ['\u0126', '\u0195', '\u04a2', '\u04ba', '\u04c7', '\u050a'],
|
@@ -19,7 +19,7 @@ module['exports'] = function runTheTrap(text, options) {
|
|
19
19
|
m: ['\u028d', '\u04cd', '\u04ce', '\u0520', '\u0521', '\u0d69'],
|
20
20
|
n: ['\u00d1', '\u014b', '\u019d', '\u0376', '\u03a0', '\u048a'],
|
21
21
|
o: ['\u00d8', '\u00f5', '\u00f8', '\u01fe', '\u0298', '\u047a', '\u05dd',
|
22
|
-
|
22
|
+
'\u06dd', '\u0e4f'],
|
23
23
|
p: ['\u01f7', '\u048e'],
|
24
24
|
q: ['\u09cd'],
|
25
25
|
r: ['\u00ae', '\u01a6', '\u0210', '\u024c', '\u0280', '\u042f'],
|
package/lib/custom/zalgo.js
CHANGED
@@ -75,21 +75,21 @@ module['exports'] = function zalgo(text, options) {
|
|
75
75
|
result = result + text[l];
|
76
76
|
counts = {'up': 0, 'down': 0, 'mid': 0};
|
77
77
|
switch (options.size) {
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
78
|
+
case 'mini':
|
79
|
+
counts.up = randomNumber(8);
|
80
|
+
counts.mid = randomNumber(2);
|
81
|
+
counts.down = randomNumber(8);
|
82
|
+
break;
|
83
|
+
case 'maxi':
|
84
|
+
counts.up = randomNumber(16) + 3;
|
85
|
+
counts.mid = randomNumber(4) + 1;
|
86
|
+
counts.down = randomNumber(64) + 3;
|
87
|
+
break;
|
88
|
+
default:
|
89
|
+
counts.up = randomNumber(8) + 1;
|
90
|
+
counts.mid = randomNumber(6) / 2;
|
91
|
+
counts.down = randomNumber(8) + 1;
|
92
|
+
break;
|
93
93
|
}
|
94
94
|
|
95
95
|
var arr = ['up', 'mid', 'down'];
|
@@ -74,16 +74,20 @@ module['exports'] = function() {
|
|
74
74
|
if (typeof(theme[prop]) === 'string') {
|
75
75
|
colors[prop] = colors[theme[prop]];
|
76
76
|
addProperty(prop, function() {
|
77
|
-
return colors[
|
77
|
+
return colors[prop](this);
|
78
78
|
});
|
79
79
|
} else {
|
80
|
-
|
81
|
-
var ret = this;
|
80
|
+
var themePropApplicator = function(str) {
|
81
|
+
var ret = str || this;
|
82
82
|
for (var t = 0; t < theme[prop].length; t++) {
|
83
83
|
ret = colors[theme[prop][t]](ret);
|
84
84
|
}
|
85
85
|
return ret;
|
86
|
-
}
|
86
|
+
};
|
87
|
+
addProperty(prop, themePropApplicator);
|
88
|
+
colors[prop] = function(str) {
|
89
|
+
return themePropApplicator(str);
|
90
|
+
};
|
87
91
|
}
|
88
92
|
}
|
89
93
|
});
|
@@ -91,14 +95,14 @@ module['exports'] = function() {
|
|
91
95
|
|
92
96
|
colors.setTheme = function(theme) {
|
93
97
|
if (typeof theme === 'string') {
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
98
|
+
console.log('colors.setTheme now only accepts an object, not a string. ' +
|
99
|
+
'If you are trying to set a theme from a file, it is now your (the ' +
|
100
|
+
'caller\'s) responsibility to require the file. The old syntax ' +
|
101
|
+
'looked like colors.setTheme(__dirname + ' +
|
102
|
+
'\'/../themes/generic-logging.js\'); The new syntax looks like '+
|
103
|
+
'colors.setTheme(require(__dirname + ' +
|
104
|
+
'\'/../themes/generic-logging.js\'));');
|
105
|
+
return;
|
102
106
|
} else {
|
103
107
|
applyTheme(theme);
|
104
108
|
}
|
package/lib/maps/america.js
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module['exports'] = (function() {
|
1
|
+
module['exports'] = function(colors) {
|
4
2
|
return function(letter, i, exploded) {
|
5
3
|
if (letter === ' ') return letter;
|
6
4
|
switch (i%3) {
|
@@ -9,4 +7,4 @@ module['exports'] = (function() {
|
|
9
7
|
case 2: return colors.blue(letter);
|
10
8
|
}
|
11
9
|
};
|
12
|
-
}
|
10
|
+
};
|
package/lib/maps/rainbow.js
CHANGED
@@ -1,6 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module['exports'] = (function() {
|
1
|
+
module['exports'] = function(colors) {
|
4
2
|
// RoY G BiV
|
5
3
|
var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta'];
|
6
4
|
return function(letter, i, exploded) {
|
@@ -10,5 +8,5 @@ module['exports'] = (function() {
|
|
10
8
|
return colors[rainbowColors[i++ % rainbowColors.length]](letter);
|
11
9
|
}
|
12
10
|
};
|
13
|
-
}
|
11
|
+
};
|
14
12
|
|
package/lib/maps/random.js
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
module['exports'] = (function() {
|
1
|
+
module['exports'] = function(colors) {
|
4
2
|
var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green',
|
5
3
|
'blue', 'white', 'cyan', 'magenta'];
|
6
4
|
return function(letter, i, exploded) {
|
7
5
|
return letter === ' ' ? letter :
|
8
6
|
colors[
|
9
|
-
|
7
|
+
available[Math.round(Math.random() * (available.length - 2))]
|
10
8
|
](letter);
|
11
9
|
};
|
12
|
-
}
|
10
|
+
};
|
package/lib/maps/zebra.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module['exports'] = function(colors) {
|
2
|
+
return function(letter, i, exploded) {
|
3
|
+
return i % 2 === 0 ? letter : colors.inverse(letter);
|
4
|
+
};
|
5
5
|
};
|
package/package.json
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "colors",
|
3
3
|
"description": "get colors in your node.js console",
|
4
|
-
"version": "1.
|
4
|
+
"version": "1.3.3",
|
5
5
|
"author": "Marak Squires",
|
6
|
+
"contributors": [
|
7
|
+
{
|
8
|
+
"name": "DABH",
|
9
|
+
"url": "https://github.com/DABH"
|
10
|
+
}
|
11
|
+
],
|
6
12
|
"homepage": "https://github.com/Marak/colors.js",
|
7
13
|
"bugs": "https://github.com/Marak/colors.js/issues",
|
8
14
|
"keywords": [
|
@@ -33,7 +39,7 @@
|
|
33
39
|
"safe.d.ts"
|
34
40
|
],
|
35
41
|
"devDependencies": {
|
36
|
-
"eslint": "^
|
37
|
-
"eslint-config-google": "^0.
|
42
|
+
"eslint": "^5.2.0",
|
43
|
+
"eslint-config-google": "^0.11.0"
|
38
44
|
}
|
39
45
|
}
|