colors 1.2.0 → 1.2.1

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.
@@ -1,45 +1,45 @@
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", "\u0a6c"],
11
- f: ["\u04fa"],
12
- g: ["\u0262"],
13
- h: ["\u0126", "\u0195", "\u04a2", "\u04ba", "\u04c7", "\u050a"],
14
- i: ["\u0f0f"],
15
- j: ["\u0134"],
16
- k: ["\u0138", "\u04a0", "\u04c3", "\u051e"],
17
- l: ["\u0139"],
18
- m: ["\u028d", "\u04cd", "\u04ce", "\u0520", "\u0521", "\u0d69"],
19
- n: ["\u00d1", "\u014b", "\u019d", "\u0376", "\u03a0", "\u048a"],
20
- o: ["\u00d8", "\u00f5", "\u00f8", "\u01fe", "\u0298", "\u047a", "\u05dd", "\u06dd", "\u0e4f"],
21
- p: ["\u01f7", "\u048e"],
22
- q: ["\u09cd"],
23
- r: ["\u00ae", "\u01a6", "\u0210", "\u024c", "\u0280", "\u042f"],
24
- s: ["\u00a7", "\u03de", "\u03df", "\u03e8"],
25
- t: ["\u0141", "\u0166", "\u0373"],
26
- u: ["\u01b1", "\u054d"],
27
- v: ["\u05d8"],
28
- w: ["\u0428", "\u0460", "\u047c", "\u0d70"],
29
- x: ["\u04b2", "\u04fe", "\u04fc", "\u04fd"],
30
- y: ["\u00a5", "\u04b0", "\u04cb"],
31
- z: ["\u01b5", "\u0240"]
32
- }
33
- text.forEach(function(c){
34
- c = c.toLowerCase();
35
- var chars = trap[c] || [" "];
36
- var rand = Math.floor(Math.random() * chars.length);
37
- if (typeof trap[c] !== "undefined") {
38
- result += trap[c][rand];
39
- } else {
40
- result += c;
41
- }
42
- });
43
- return result;
44
-
45
- }
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", "\u0a6c"],
11
+ f: ["\u04fa"],
12
+ g: ["\u0262"],
13
+ h: ["\u0126", "\u0195", "\u04a2", "\u04ba", "\u04c7", "\u050a"],
14
+ i: ["\u0f0f"],
15
+ j: ["\u0134"],
16
+ k: ["\u0138", "\u04a0", "\u04c3", "\u051e"],
17
+ l: ["\u0139"],
18
+ m: ["\u028d", "\u04cd", "\u04ce", "\u0520", "\u0521", "\u0d69"],
19
+ n: ["\u00d1", "\u014b", "\u019d", "\u0376", "\u03a0", "\u048a"],
20
+ o: ["\u00d8", "\u00f5", "\u00f8", "\u01fe", "\u0298", "\u047a", "\u05dd", "\u06dd", "\u0e4f"],
21
+ p: ["\u01f7", "\u048e"],
22
+ q: ["\u09cd"],
23
+ r: ["\u00ae", "\u01a6", "\u0210", "\u024c", "\u0280", "\u042f"],
24
+ s: ["\u00a7", "\u03de", "\u03df", "\u03e8"],
25
+ t: ["\u0141", "\u0166", "\u0373"],
26
+ u: ["\u01b1", "\u054d"],
27
+ v: ["\u05d8"],
28
+ w: ["\u0428", "\u0460", "\u047c", "\u0d70"],
29
+ x: ["\u04b2", "\u04fe", "\u04fc", "\u04fd"],
30
+ y: ["\u00a5", "\u04b0", "\u04cb"],
31
+ z: ["\u01b5", "\u0240"]
32
+ }
33
+ text.forEach(function(c){
34
+ c = c.toLowerCase();
35
+ var chars = trap[c] || [" "];
36
+ var rand = Math.floor(Math.random() * chars.length);
37
+ if (typeof trap[c] !== "undefined") {
38
+ result += trap[c][rand];
39
+ } else {
40
+ result += c;
41
+ }
42
+ });
43
+ return result;
44
+
45
+ }
@@ -1,104 +1,104 @@
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
- all = [].concat(soul.up, soul.down, soul.mid),
42
- zalgo = {};
43
-
44
- function randomNumber(range) {
45
- var r = Math.floor(Math.random() * range);
46
- return r;
47
- }
48
-
49
- function is_char(character) {
50
- var bool = false;
51
- all.filter(function (i) {
52
- bool = (i === character);
53
- });
54
- return bool;
55
- }
56
-
57
-
58
- function heComes(text, options) {
59
- var result = '', counts, l;
60
- options = options || {};
61
- options["up"] = typeof options["up"] !== 'undefined' ? options["up"] : true;
62
- options["mid"] = typeof options["mid"] !== 'undefined' ? options["mid"] : true;
63
- options["down"] = typeof options["down"] !== 'undefined' ? options["down"] : true;
64
- options["size"] = typeof options["size"] !== 'undefined' ? options["size"] : "maxi";
65
- text = text.split('');
66
- for (l in text) {
67
- if (is_char(l)) {
68
- continue;
69
- }
70
- result = result + text[l];
71
- counts = {"up" : 0, "down" : 0, "mid" : 0};
72
- switch (options.size) {
73
- case 'mini':
74
- counts.up = randomNumber(8);
75
- counts.mid = randomNumber(2);
76
- counts.down = randomNumber(8);
77
- break;
78
- case 'maxi':
79
- counts.up = randomNumber(16) + 3;
80
- counts.mid = randomNumber(4) + 1;
81
- counts.down = randomNumber(64) + 3;
82
- break;
83
- default:
84
- counts.up = randomNumber(8) + 1;
85
- counts.mid = randomNumber(6) / 2;
86
- counts.down = randomNumber(8) + 1;
87
- break;
88
- }
89
-
90
- var arr = ["up", "mid", "down"];
91
- for (var d in arr) {
92
- var index = arr[d];
93
- for (var i = 0 ; i <= counts[index]; i++) {
94
- if (options[index]) {
95
- result = result + soul[index][randomNumber(soul[index].length)];
96
- }
97
- }
98
- }
99
- }
100
- return result;
101
- }
102
- // don't summon him
103
- return heComes(text, options);
104
- }
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
+ all = [].concat(soul.up, soul.down, soul.mid),
42
+ zalgo = {};
43
+
44
+ function randomNumber(range) {
45
+ var r = Math.floor(Math.random() * range);
46
+ return r;
47
+ }
48
+
49
+ function is_char(character) {
50
+ var bool = false;
51
+ all.filter(function (i) {
52
+ bool = (i === character);
53
+ });
54
+ return bool;
55
+ }
56
+
57
+
58
+ function heComes(text, options) {
59
+ var result = '', counts, l;
60
+ options = options || {};
61
+ options["up"] = typeof options["up"] !== 'undefined' ? options["up"] : true;
62
+ options["mid"] = typeof options["mid"] !== 'undefined' ? options["mid"] : true;
63
+ options["down"] = typeof options["down"] !== 'undefined' ? options["down"] : true;
64
+ options["size"] = typeof options["size"] !== 'undefined' ? options["size"] : "maxi";
65
+ text = text.split('');
66
+ for (l in text) {
67
+ if (is_char(l)) {
68
+ continue;
69
+ }
70
+ result = result + text[l];
71
+ counts = {"up" : 0, "down" : 0, "mid" : 0};
72
+ switch (options.size) {
73
+ case 'mini':
74
+ counts.up = randomNumber(8);
75
+ counts.mid = randomNumber(2);
76
+ counts.down = randomNumber(8);
77
+ break;
78
+ case 'maxi':
79
+ counts.up = randomNumber(16) + 3;
80
+ counts.mid = randomNumber(4) + 1;
81
+ counts.down = randomNumber(64) + 3;
82
+ break;
83
+ default:
84
+ counts.up = randomNumber(8) + 1;
85
+ counts.mid = randomNumber(6) / 2;
86
+ counts.down = randomNumber(8) + 1;
87
+ break;
88
+ }
89
+
90
+ var arr = ["up", "mid", "down"];
91
+ for (var d in arr) {
92
+ var index = arr[d];
93
+ for (var i = 0 ; i <= counts[index]; i++) {
94
+ if (options[index]) {
95
+ result = result + soul[index][randomNumber(soul[index].length)];
96
+ }
97
+ }
98
+ }
99
+ }
100
+ return result;
101
+ }
102
+ // don't summon him
103
+ return heComes(text, options);
104
+ }
@@ -1,113 +1,113 @@
1
- var colors = require('./colors');
2
-
3
- module['exports'] = function () {
4
-
5
- //
6
- // Extends prototype of native string object to allow for "foo".red syntax
7
- //
8
- var addProperty = function (color, func) {
9
- String.prototype.__defineGetter__(color, func);
10
- };
11
-
12
- var sequencer = function sequencer (map, str) {
13
- return function () {
14
- var exploded = this.split(""), i = 0;
15
- exploded = exploded.map(map);
16
- return exploded.join("");
17
- }
18
- };
19
-
20
- addProperty('strip', function () {
21
- return colors.strip(this);
22
- });
23
-
24
- addProperty('stripColors', function () {
25
- return colors.strip(this);
26
- });
27
-
28
- addProperty("trap", function(){
29
- return colors.trap(this);
30
- });
31
-
32
- addProperty("zalgo", function(){
33
- return colors.zalgo(this);
34
- });
35
-
36
- addProperty("zebra", function(){
37
- return colors.zebra(this);
38
- });
39
-
40
- addProperty("rainbow", function(){
41
- return colors.rainbow(this);
42
- });
43
-
44
- addProperty("random", function(){
45
- return colors.random(this);
46
- });
47
-
48
- addProperty("america", function(){
49
- return colors.america(this);
50
- });
51
-
52
- //
53
- // Iterate through all default styles and colors
54
- //
55
- var x = Object.keys(colors.styles);
56
- x.forEach(function (style) {
57
- addProperty(style, function () {
58
- return colors.stylize(this, style);
59
- });
60
- });
61
-
62
- function applyTheme(theme) {
63
- //
64
- // Remark: This is a list of methods that exist
65
- // on String that you should not overwrite.
66
- //
67
- var stringPrototypeBlacklist = [
68
- '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'charAt', 'constructor',
69
- 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf', 'charCodeAt',
70
- 'indexOf', 'lastIndexof', 'length', 'localeCompare', 'match', 'repeat', 'replace', 'search', 'slice', 'split', 'substring',
71
- 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight'
72
- ];
73
-
74
- Object.keys(theme).forEach(function (prop) {
75
- if (stringPrototypeBlacklist.indexOf(prop) !== -1) {
76
- console.log('warn: '.red + ('String.prototype' + prop).magenta + ' is probably something you don\'t want to override. Ignoring style name');
77
- }
78
- else {
79
- if (typeof(theme[prop]) === 'string') {
80
- colors[prop] = colors[theme[prop]];
81
- addProperty(prop, function () {
82
- return colors[theme[prop]](this);
83
- });
84
- }
85
- else {
86
- addProperty(prop, function () {
87
- var ret = this;
88
- for (var t = 0; t < theme[prop].length; t++) {
89
- ret = colors[theme[prop][t]](ret);
90
- }
91
- return ret;
92
- });
93
- }
94
- }
95
- });
96
- }
97
-
98
- colors.setTheme = function (theme) {
99
- if (typeof theme === 'string') {
100
- try {
101
- colors.themes[theme] = require(theme);
102
- applyTheme(colors.themes[theme]);
103
- return colors.themes[theme];
104
- } catch (err) {
105
- console.log(err);
106
- return err;
107
- }
108
- } else {
109
- applyTheme(theme);
110
- }
111
- };
112
-
113
- };
1
+ var colors = require('./colors');
2
+
3
+ module['exports'] = function () {
4
+
5
+ //
6
+ // Extends prototype of native string object to allow for "foo".red syntax
7
+ //
8
+ var addProperty = function (color, func) {
9
+ String.prototype.__defineGetter__(color, func);
10
+ };
11
+
12
+ var sequencer = function sequencer (map, str) {
13
+ return function () {
14
+ var exploded = this.split(""), i = 0;
15
+ exploded = exploded.map(map);
16
+ return exploded.join("");
17
+ }
18
+ };
19
+
20
+ addProperty('strip', function () {
21
+ return colors.strip(this);
22
+ });
23
+
24
+ addProperty('stripColors', function () {
25
+ return colors.strip(this);
26
+ });
27
+
28
+ addProperty("trap", function(){
29
+ return colors.trap(this);
30
+ });
31
+
32
+ addProperty("zalgo", function(){
33
+ return colors.zalgo(this);
34
+ });
35
+
36
+ addProperty("zebra", function(){
37
+ return colors.zebra(this);
38
+ });
39
+
40
+ addProperty("rainbow", function(){
41
+ return colors.rainbow(this);
42
+ });
43
+
44
+ addProperty("random", function(){
45
+ return colors.random(this);
46
+ });
47
+
48
+ addProperty("america", function(){
49
+ return colors.america(this);
50
+ });
51
+
52
+ //
53
+ // Iterate through all default styles and colors
54
+ //
55
+ var x = Object.keys(colors.styles);
56
+ x.forEach(function (style) {
57
+ addProperty(style, function () {
58
+ return colors.stylize(this, style);
59
+ });
60
+ });
61
+
62
+ function applyTheme(theme) {
63
+ //
64
+ // Remark: This is a list of methods that exist
65
+ // on String that you should not overwrite.
66
+ //
67
+ var stringPrototypeBlacklist = [
68
+ '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'charAt', 'constructor',
69
+ 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf', 'charCodeAt',
70
+ 'indexOf', 'lastIndexof', 'length', 'localeCompare', 'match', 'repeat', 'replace', 'search', 'slice', 'split', 'substring',
71
+ 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight'
72
+ ];
73
+
74
+ Object.keys(theme).forEach(function (prop) {
75
+ if (stringPrototypeBlacklist.indexOf(prop) !== -1) {
76
+ console.log('warn: '.red + ('String.prototype' + prop).magenta + ' is probably something you don\'t want to override. Ignoring style name');
77
+ }
78
+ else {
79
+ if (typeof(theme[prop]) === 'string') {
80
+ colors[prop] = colors[theme[prop]];
81
+ addProperty(prop, function () {
82
+ return colors[theme[prop]](this);
83
+ });
84
+ }
85
+ else {
86
+ addProperty(prop, function () {
87
+ var ret = this;
88
+ for (var t = 0; t < theme[prop].length; t++) {
89
+ ret = colors[theme[prop][t]](ret);
90
+ }
91
+ return ret;
92
+ });
93
+ }
94
+ }
95
+ });
96
+ }
97
+
98
+ colors.setTheme = function (theme) {
99
+ if (typeof theme === 'string') {
100
+ try {
101
+ colors.themes[theme] = require(theme);
102
+ applyTheme(colors.themes[theme]);
103
+ return colors.themes[theme];
104
+ } catch (err) {
105
+ console.log(err);
106
+ return err;
107
+ }
108
+ } else {
109
+ applyTheme(theme);
110
+ }
111
+ };
112
+
113
+ };
package/lib/index.js CHANGED
@@ -1,12 +1,12 @@
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 native String will not be touched
7
- //
8
- // var colors = require('colors/safe);
9
- // colors.red("foo")
10
- //
11
- //
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 native String will not be touched
7
+ //
8
+ // var colors = require('colors/safe);
9
+ // colors.red("foo")
10
+ //
11
+ //
12
12
  require('./extendStringPrototype')();
@@ -1,12 +1,12 @@
1
- var colors = require('../colors');
2
-
3
- module['exports'] = (function() {
4
- return function (letter, i, exploded) {
5
- if(letter === " ") return letter;
6
- switch(i%3) {
7
- case 0: return colors.red(letter);
8
- case 1: return colors.white(letter)
9
- case 2: return colors.blue(letter)
10
- }
11
- }
1
+ var colors = require('../colors');
2
+
3
+ module['exports'] = (function() {
4
+ return function (letter, i, exploded) {
5
+ if(letter === " ") return letter;
6
+ switch(i%3) {
7
+ case 0: return colors.red(letter);
8
+ case 1: return colors.white(letter)
9
+ case 2: return colors.blue(letter)
10
+ }
11
+ }
12
12
  })();
@@ -1,13 +1,13 @@
1
- var colors = require('../colors');
2
-
3
- module['exports'] = (function () {
4
- var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta']; //RoY G BiV
5
- return function (letter, i, exploded) {
6
- if (letter === " ") {
7
- return letter;
8
- } else {
9
- return colors[rainbowColors[i++ % rainbowColors.length]](letter);
10
- }
11
- };
12
- })();
13
-
1
+ var colors = require('../colors');
2
+
3
+ module['exports'] = (function () {
4
+ var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta']; //RoY G BiV
5
+ return function (letter, i, exploded) {
6
+ if (letter === " ") {
7
+ return letter;
8
+ } else {
9
+ return colors[rainbowColors[i++ % rainbowColors.length]](letter);
10
+ }
11
+ };
12
+ })();
13
+
@@ -1,8 +1,8 @@
1
- var colors = require('../colors');
2
-
3
- module['exports'] = (function () {
4
- var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'];
5
- return function(letter, i, exploded) {
6
- return letter === " " ? letter : colors[available[Math.round(Math.random() * (available.length - 1))]](letter);
7
- };
1
+ var colors = require('../colors');
2
+
3
+ module['exports'] = (function () {
4
+ var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'];
5
+ return function(letter, i, exploded) {
6
+ return letter === " " ? letter : colors[available[Math.round(Math.random() * (available.length - 1))]](letter);
7
+ };
8
8
  })();
package/lib/maps/zebra.js CHANGED
@@ -1,5 +1,5 @@
1
- var colors = require('../colors');
2
-
3
- module['exports'] = function (letter, i, exploded) {
4
- return i % 2 === 0 ? letter : colors.inverse(letter);
1
+ var colors = require('../colors');
2
+
3
+ module['exports'] = function (letter, i, exploded) {
4
+ return i % 2 === 0 ? letter : colors.inverse(letter);
5
5
  };