X-Git-Url: https://git.r.bdr.sh/rbdr/cologne/blobdiff_plain/ae85c067634676251e812765c81adfdef8f85f9d..c5c1edf756baf83f61f1f640ea14fef71128608f:/lib/utilities.js?ds=inline diff --git a/lib/utilities.js b/lib/utilities.js index 1c930af..8bb226b 100644 --- a/lib/utilities.js +++ b/lib/utilities.js @@ -2,6 +2,37 @@ const internals = { kCircularString: '[Circular]', + kAnsiCodes: { + bold: '[1m', + italics: '[3m', + underline: '[4m', + inverse: '[7m', + strikethrough: '[9m', + bold_off: '[22m', + italics_off: '[23m', + underline_off: '[24m', + inverse_off: '[27m', + strikethrough_off: '[29m', + black: '[30m', + red: '[31m', + green: '[32m', + yellow: '[33m', + blue: '[34m', + magenta: '[35m', + cyan: '[36m', + white: '[37m', + default: '[39m', + black_bg: '[40m', + red_bg: '[41m', + green_bg: '[42m', + yellow_bg: '[43m', + blue_bg: '[44m', + magenta_bg: '[45m', + cyan_bg: '[46m', + white_bg: '[47m', + default_bg: '[49m', + reset: '[0m' + }, // Get High Res time depending on platform. Currently only supporting node. @@ -75,67 +106,7 @@ module.exports = { */ getAnsiCode(ansiString) { - switch (ansiString) { - case 'bold': - return '[1m'; - case 'italics': - return '[3m'; - case 'underline': - return '[4m'; - case 'inverse': - return '[7m'; - case 'strikethrough': - return '[9m'; - case 'bold_off': - return '[22m'; - case 'italics_off': - return '[23m'; - case 'underline_off': - return '[24m'; - case 'inverse_off': - return '[27m'; - case 'strikethrough_off': - return '[29m'; - case 'black': - return '[30m'; - case 'red': - return '[31m'; - case 'green': - return '[32m'; - case 'yellow': - return '[33m'; - case 'blue': - return '[34m'; - case 'magenta': - return '[35m'; - case 'cyan': - return '[36m'; - case 'white': - return '[37m'; - case 'default': - return '[39m'; - case 'black_bg': - return '[40m'; - case 'red_bg': - return '[41m'; - case 'green_bg': - return '[42m'; - case 'yellow_bg': - return '[43m'; - case 'blue_bg': - return '[44m'; - case 'magenta_bg': - return '[45m'; - case 'cyan_bg': - return '[46m'; - case 'white_bg': - return '[47m'; - case 'default_bg': - return '[49m'; - case 'reset': // for informative purpouses - default: - return '[0m'; - } + return internals.kAnsiCodes[ansiString] || internals.kAnsiCodes.reset; }, /**