Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
solving circular references
  • Loading branch information
adrielcodeco authored and DABH committed Jul 22, 2018
1 parent 7aa37ff commit f35d715
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
8 changes: 4 additions & 4 deletions lib/colors.js
Expand Up @@ -185,10 +185,10 @@ colors.zalgo = require('./custom/zalgo');

// maps
colors.maps = {};
colors.maps.america = require('./maps/america');
colors.maps.zebra = require('./maps/zebra');
colors.maps.rainbow = require('./maps/rainbow');
colors.maps.random = require('./maps/random');
colors.maps.america = require('./maps/america')(colors);
colors.maps.zebra = require('./maps/zebra')(colors);
colors.maps.rainbow = require('./maps/rainbow')(colors);
colors.maps.random = require('./maps/random')(colors);

for (var map in colors.maps) {
(function(map) {
Expand Down
6 changes: 2 additions & 4 deletions lib/maps/america.js
@@ -1,6 +1,4 @@
var colors = require('../colors');

module['exports'] = (function() {
module['exports'] = function(colors) {
return function(letter, i, exploded) {
if (letter === ' ') return letter;
switch (i%3) {
Expand All @@ -9,4 +7,4 @@ module['exports'] = (function() {
case 2: return colors.blue(letter);
}
};
})();
};
6 changes: 2 additions & 4 deletions lib/maps/rainbow.js
@@ -1,6 +1,4 @@
var colors = require('../colors');

module['exports'] = (function() {
module['exports'] = function(colors) {
// RoY G BiV
var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta'];
return function(letter, i, exploded) {
Expand All @@ -10,5 +8,5 @@ module['exports'] = (function() {
return colors[rainbowColors[i++ % rainbowColors.length]](letter);
}
};
})();
};

6 changes: 2 additions & 4 deletions lib/maps/random.js
@@ -1,6 +1,4 @@
var colors = require('../colors');

module['exports'] = (function() {
module['exports'] = function(colors) {
var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green',
'blue', 'white', 'cyan', 'magenta'];
return function(letter, i, exploded) {
Expand All @@ -9,4 +7,4 @@ module['exports'] = (function() {
available[Math.round(Math.random() * (available.length - 2))]
](letter);
};
})();
};
8 changes: 4 additions & 4 deletions lib/maps/zebra.js
@@ -1,5 +1,5 @@
var colors = require('../colors');

module['exports'] = function(letter, i, exploded) {
return i % 2 === 0 ? letter : colors.inverse(letter);
module['exports'] = function(colors) {
return function(letter, i, exploded) {
return i % 2 === 0 ? letter : colors.inverse(letter);
};
};

0 comments on commit f35d715

Please sign in to comment.