lighter-colors
The lighter-colors
module is a lightweight terminal color utility.
Installation
From your project directory, install and save as a dependency:
npm install --save lighter-colors
Usage
Upon requiring lighter-colors
, the String prototype is modified so that all
strings have access to color properties which output color versions of
themselves:
consoleconsoleconsole
If you would like to disable color, you can use a --no-color
argument, use
the disable method:
var colors = colorsconsole colorsconsole
Here's the full list of exported colors:
reset: '\u001b[0m' base: '\u001b[39m' bgBase: '\u001b[49m' bold: '\u001b[1m' normal: '\u001b[2m' italic: '\u001b[3m' underline: '\u001b[4m' inverse: '\u001b[7m' hidden: '\u001b[8m' strike: '\u001b[9m' black: '\u001b[30m' red: '\u001b[31m' green: '\u001b[32m' yellow: '\u001b[33m' blue: '\u001b[34m' magenta: '\u001b[35m' cyan: '\u001b[36m' white: '\u001b[37m' gray: '\u001b[90m' bgBlack: '\u001b[40m' bgRed: '\u001b[41m' bgGreen: '\u001b[42m' bgYellow: '\u001b[43m' bgBlue: '\u001b[44m' bgMagenta: '\u001b[45m' bgCyan: '\u001b[46m' bgWhite: '\u001b[47m'
In addition to the getter properties for the colors in the list above, there's
also a plain
getter property which removes colors from a colorful string:
var colorful = 'Blue'bluevar colorless = colorfulplain
And if you would like to use the color sequences without invoking getter
properties, lighter-colors
exports them for you:
var colors = var red = colorsredvar white = colorswhitevar blue = colorsbluevar base = colorsbaseconsole