No Description

example.js 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. var colors = require('./colors');
  2. //colors.mode = "browser";
  3. var test = colors.red("hopefully colorless output");
  4. console.log('Rainbows are fun!'.rainbow);
  5. console.log('So '.italic + 'are'.underline + ' styles! '.bold + 'inverse'.inverse); // styles not widely supported
  6. console.log('Chains are also cool.'.bold.italic.underline.red); // styles not widely supported
  7. //console.log('zalgo time!'.zalgo);
  8. console.log(test.stripColors);
  9. console.log("a".grey + " b".black);
  10. console.log("Zebras are so fun!".zebra);
  11. console.log('background color attack!'.black.whiteBG)
  12. //
  13. // Remark: .strikethrough may not work with Mac OS Terminal App
  14. //
  15. console.log("This is " + "not".strikethrough + " fun.");
  16. console.log(colors.rainbow('Rainbows are fun!'));
  17. console.log(colors.italic('So ') + colors.underline('are') + colors.bold(' styles! ') + colors.inverse('inverse')); // styles not widely supported
  18. console.log(colors.bold(colors.italic(colors.underline(colors.red('Chains are also cool.'))))); // styles not widely supported
  19. //console.log(colors.zalgo('zalgo time!'));
  20. console.log(colors.stripColors(test));
  21. console.log(colors.grey("a") + colors.black(" b"));
  22. colors.addSequencer("america", function(letter, i, exploded) {
  23. if(letter === " ") return letter;
  24. switch(i%3) {
  25. case 0: return letter.red;
  26. case 1: return letter.white;
  27. case 2: return letter.blue;
  28. }
  29. });
  30. colors.addSequencer("random", (function() {
  31. var available = ['bold', 'underline', 'italic', 'inverse', 'grey', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta'];
  32. return function(letter, i, exploded) {
  33. return letter === " " ? letter : letter[available[Math.round(Math.random() * (available.length - 1))]];
  34. };
  35. })());
  36. console.log("AMERICA! F--K YEAH!".america);
  37. console.log("So apparently I've been to Mars, with all the little green men. But you know, I don't recall.".random);
  38. //
  39. // Custom themes
  40. //
  41. // Load theme with JSON literal
  42. colors.setTheme({
  43. silly: 'rainbow',
  44. input: 'grey',
  45. verbose: 'cyan',
  46. prompt: 'grey',
  47. info: 'green',
  48. data: 'grey',
  49. help: 'cyan',
  50. warn: 'yellow',
  51. debug: 'blue',
  52. error: 'red'
  53. });
  54. // outputs red text
  55. console.log("this is an error".error);
  56. // outputs yellow text
  57. console.log("this is a warning".warn);
  58. // outputs grey text
  59. console.log("this is an input".input);
  60. // Load a theme from file
  61. colors.setTheme('./themes/winston-dark.js');
  62. console.log("this is an input".input);