pissbot-9000/labscore/utils/ansi.js
derpystuff 6173b085a3 wip
2022-05-21 16:21:08 +02:00

33 lines
No EOL
610 B
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const ANSI_COLORS = {
"reset": "",
"black": "",
"red": "",
"green": "",
"yellow": "",
"blue": "",
"magenta": "",
"cyan": "",
"white": ""
}
const ALIASES = {
"b": "black",
"r": "red",
"g": "green",
"y": "yellow",
"bl": "blue",
"m": "magenta",
"c": "cyan",
"w": "white",
"rs": "reset"
}
function format(text, color){
if(!ANSI_COLORS[color] && !ALIASES[color]) throw "Invalid ANSI Color"
if(!ANSI_COLORS[color]) color = ALIASES[color]
return `${ANSI_COLORS[color]}${text}${ANSI_COLORS.reset}`
}
module.exports = {
format
}