verbalize
Version:
A pluggable logging utility with built-in colors, styles, and modes.
42 lines (36 loc) • 788 B
JavaScript
/**
* Why? Because we all deserve to have more
* color in the console.
*
* @return {String}
* @api public
*/
module.exports = function(options) {
return function(app) {
app.style('rainbow', function() {
var args = [].slice.call(arguments);
var colors = [
'red',
'yellow',
'green',
'blue',
'cyan',
'magenta',
'bold',
'white'
];
var len = colors.length;
function tasteTheRainbow(str) {
return str.split('').map(function(ele, i) {
if (ele === ' ') {
return ele;
} else {
return app[colors[i++ % len]](ele);
}
}).join('');
}
return tasteTheRainbow.call(this, args[0]);
});
};
};
;