From c11d23d96aee270bcfc8761c1f6c20579def88f3 Mon Sep 17 00:00:00 2001 From: David Konsumer Date: Tue, 20 Jan 2015 16:48:44 -0800 Subject: [PATCH] resolves #72 --- ReadMe.md | 12 ++++++++++++ lib/colors.js | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/ReadMe.md b/ReadMe.md index beb5b14..1d608d5 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -162,6 +162,18 @@ console.log(colors.error("this is an error")); // outputs yellow text console.log(colors.warn("this is a warning")); + +``` + +You can also combine them: + +```javascript +colors.setTheme({ + link: ['underline', 'blue'] +}); + +// outputs underlined blue text +console.log(colors.info('Listening on ') + colors.link('http://0.0.0.0:' + port) ); ``` *Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.* \ No newline at end of file diff --git a/lib/colors.js b/lib/colors.js index 59898de..6616f11 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -115,6 +115,13 @@ function applyTheme (theme) { for (var style in theme) { (function(style){ colors[style] = function(str){ + if (typeof theme[style] === 'object'){ + var out = str; + for (var i in theme[style]){ + out = colors[theme[style][i]](out); + } + return out; + } return colors[theme[style]](str); }; })(style)