Skip to content

Commit 21abbcb

Browse files
authored
Merge pull request #236 from Marak/solve-circular-refs
Solve circular refs
2 parents 7aa37ff + c76ec61 commit 21abbcb

File tree

7 files changed

+19
-25
lines changed

7 files changed

+19
-25
lines changed

examples/safe-string.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ console.log('Setting themes is useful');
3737
// Load theme with JSON literal
3838
colors.setTheme({
3939
silly: 'rainbow',
40-
input: 'grey',
40+
input: 'blue',
4141
verbose: 'cyan',
4242
prompt: 'grey',
4343
info: 'green',
@@ -54,14 +54,14 @@ console.log(colors.error('this is an error'));
5454
// outputs yellow text
5555
console.log(colors.warn('this is a warning'));
5656

57-
// outputs grey text
57+
// outputs blue text
5858
console.log(colors.input('this is an input'));
5959

6060

6161
// console.log('Generic logging theme as file'.green.bold.underline);
6262

6363
// Load a theme from file
64-
colors.setTheme(__dirname + '/../themes/generic-logging.js');
64+
colors.setTheme(require(__dirname + '/../themes/generic-logging.js'));
6565

6666
// outputs red text
6767
console.log(colors.error('this is an error'));

index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ declare global {
116116
bgCyan: string;
117117
bgWhite: string;
118118

119-
reset: string;
120-
// @ts-ignore
119+
reset: string;
120+
// @ts-ignore
121121
bold: string;
122122
dim: string;
123123
italic: string;

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)