From f35d715e046cf07c41f7d31eb57d6c16ed4d0f4d Mon Sep 17 00:00:00 2001 From: pii Date: Thu, 19 Jul 2018 23:05:46 -0300 Subject: [PATCH 1/4] solving circular references --- lib/colors.js | 8 ++++---- lib/maps/america.js | 6 ++---- lib/maps/rainbow.js | 6 ++---- lib/maps/random.js | 6 ++---- lib/maps/zebra.js | 8 ++++---- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/lib/colors.js b/lib/colors.js index 74272ba8..7ca90fa9 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -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) { diff --git a/lib/maps/america.js b/lib/maps/america.js index 86700529..dc969033 100644 --- a/lib/maps/america.js +++ b/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) { @@ -9,4 +7,4 @@ module['exports'] = (function() { case 2: return colors.blue(letter); } }; -})(); +}; diff --git a/lib/maps/rainbow.js b/lib/maps/rainbow.js index 4e7ef006..2b00ac0a 100644 --- a/lib/maps/rainbow.js +++ b/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) { @@ -10,5 +8,5 @@ module['exports'] = (function() { return colors[rainbowColors[i++ % rainbowColors.length]](letter); } }; -})(); +}; diff --git a/lib/maps/random.js b/lib/maps/random.js index 88219daf..cf93df2a 100644 --- a/lib/maps/random.js +++ b/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) { @@ -9,4 +7,4 @@ module['exports'] = (function() { available[Math.round(Math.random() * (available.length - 2))] ](letter); }; -})(); +}; diff --git a/lib/maps/zebra.js b/lib/maps/zebra.js index 28938c02..fa736235 100644 --- a/lib/maps/zebra.js +++ b/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); + }; }; From cfef595ebb38c2e8cef8edc864f63feb057ea9fd Mon Sep 17 00:00:00 2001 From: pii Date: Thu, 19 Jul 2018 23:05:46 -0300 Subject: [PATCH 2/4] solving circular references From 3492add94bfe984e741fab439fd3103741c7da6b Mon Sep 17 00:00:00 2001 From: DABH Date: Sun, 22 Jul 2018 14:17:35 -0700 Subject: [PATCH 3/4] Update safe mode examples to avoid deprecated setTheme syntax --- examples/safe-string.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/safe-string.js b/examples/safe-string.js index 7a836537..98994873 100644 --- a/examples/safe-string.js +++ b/examples/safe-string.js @@ -37,7 +37,7 @@ console.log('Setting themes is useful'); // Load theme with JSON literal colors.setTheme({ silly: 'rainbow', - input: 'grey', + input: 'blue', verbose: 'cyan', prompt: 'grey', info: 'green', @@ -54,14 +54,14 @@ console.log(colors.error('this is an error')); // outputs yellow text console.log(colors.warn('this is a warning')); -// outputs grey text +// outputs blue text console.log(colors.input('this is an input')); // console.log('Generic logging theme as file'.green.bold.underline); // Load a theme from file -colors.setTheme(__dirname + '/../themes/generic-logging.js'); +colors.setTheme(require(__dirname + '/../themes/generic-logging.js')); // outputs red text console.log(colors.error('this is an error')); From c76ec61860114f9a2b31ac7e41015ab9e5ac6e04 Mon Sep 17 00:00:00 2001 From: DABH Date: Sun, 22 Jul 2018 14:19:05 -0700 Subject: [PATCH 4/4] spaces v tabs --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index faa9ab69..baa70686 100644 --- a/index.d.ts +++ b/index.d.ts @@ -116,8 +116,8 @@ declare global { bgCyan: string; bgWhite: string; - reset: string; - // @ts-ignore + reset: string; + // @ts-ignore bold: string; dim: string; italic: string;