Skip to content

Commit f35d715

Browse files
adrielcodecoDABH
authored andcommitted
solving circular references
1 parent 7aa37ff commit f35d715

File tree

5 files changed

+14
-20
lines changed

5 files changed

+14
-20
lines changed

lib/colors.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ colors.zalgo = require('./custom/zalgo');
185185

186186
// maps
187187
colors.maps = {};
188-
colors.maps.america = require('./maps/america');
189-
colors.maps.zebra = require('./maps/zebra');
190-
colors.maps.rainbow = require('./maps/rainbow');
191-
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);
192192

193193
for (var map in colors.maps) {
194194
(function(map) {

lib/maps/america.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
var colors = require('../colors');
2-
3-
module['exports'] = (function() {
1+
module['exports'] = function(colors) {
42
return function(letter, i, exploded) {
53
if (letter === ' ') return letter;
64
switch (i%3) {
@@ -9,4 +7,4 @@ module['exports'] = (function() {
97
case 2: return colors.blue(letter);
108
}
119
};
12-
})();
10+
};

lib/maps/rainbow.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
var colors = require('../colors');
2-
3-
module['exports'] = (function() {
1+
module['exports'] = function(colors) {
42
// RoY G BiV
53
var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta'];
64
return function(letter, i, exploded) {
@@ -10,5 +8,5 @@ module['exports'] = (function() {
108
return colors[rainbowColors[i++ % rainbowColors.length]](letter);
119
}
1210
};
13-
})();
11+
};
1412

lib/maps/random.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
var colors = require('../colors');
2-
3-
module['exports'] = (function() {
1+
module['exports'] = function(colors) {
42
var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green',
53
'blue', 'white', 'cyan', 'magenta'];
64
return function(letter, i, exploded) {
@@ -9,4 +7,4 @@ module['exports'] = (function() {
97
available[Math.round(Math.random() * (available.length - 2))]
108
](letter);
119
};
12-
})();
10+
};

lib/maps/zebra.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
module['exports'] = function(colors) {
2+
return function(letter, i, exploded) {
3+
return i % 2 === 0 ? letter : colors.inverse(letter);
4+
};
55
};

0 commit comments

Comments
 (0)