index.js 770 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict';
  2. var styles = module.exports;
  3. var codes = {
  4. reset: [0, 0],
  5. bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
  6. dim: [2, 22],
  7. italic: [3, 23],
  8. underline: [4, 24],
  9. inverse: [7, 27],
  10. hidden: [8, 28],
  11. strikethrough: [9, 29],
  12. black: [30, 39],
  13. red: [31, 39],
  14. green: [32, 39],
  15. yellow: [33, 39],
  16. blue: [34, 39],
  17. magenta: [35, 39],
  18. cyan: [36, 39],
  19. white: [37, 39],
  20. gray: [90, 39],
  21. bgBlack: [40, 49],
  22. bgRed: [41, 49],
  23. bgGreen: [42, 49],
  24. bgYellow: [43, 49],
  25. bgBlue: [44, 49],
  26. bgMagenta: [45, 49],
  27. bgCyan: [46, 49],
  28. bgWhite: [47, 49]
  29. };
  30. Object.keys(codes).forEach(function (key) {
  31. var val = codes[key];
  32. var style = styles[key] = {};
  33. style.open = '\u001b[' + val[0] + 'm';
  34. style.close = '\u001b[' + val[1] + 'm';
  35. });