Added rainbow styling
This commit is contained in:
parent
0133342393
commit
24e6a26bbb
2 changed files with 21 additions and 0 deletions
17
chalk.js
17
chalk.js
|
|
@ -60,3 +60,20 @@ chalk.supportsColor = require('has-color');
|
|||
if (chalk.enabled === undefined) {
|
||||
chalk.enabled = chalk.supportsColor;
|
||||
}
|
||||
|
||||
// rainbow style
|
||||
var rainbowColors = [
|
||||
chalk.red,
|
||||
chalk.yellow,
|
||||
chalk.green,
|
||||
chalk.blue,
|
||||
chalk.magenta
|
||||
];
|
||||
chalk.rainbow = function(str) {
|
||||
var arStr = str.split(''),
|
||||
out = '';
|
||||
for (var i in arStr) {
|
||||
out += rainbowColors[i % rainbowColors.length](arStr[i]);
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue