GitHub Actions workflows status
CodeClimate
Installation
npm i @kaskadi/better-colors
API documentation
better-colors
Generate ANSI color code for the given color
Param | Type | Description |
---|---|---|
color | string |
Color to convert to equivalent ANSI code. Accepts: regular color names (red , etc.), RGB and HEX. |
Properties
Name | Type | Default | Description |
---|---|---|---|
[RESET] | string |
'\x1b[0m' |
Gives the ANSI code to reset colors in terminal. |
Example
const color = require('better-colors')
// will all print '\u001b[38;2;255;0;0m\u001b[10m'
console.log(color('red'))
console.log(color('#ff0000'))
console.log(color(255, 0, 0))
// will print '\u001b[48;2;255;0;0m\u001b[10m'
console.log(color('red', 1))
// will print '\x1b[0m'
console.log(color.RESET)