@kaskadi/better-colors

![](https://img.shields.io/github/package-json/v/kaskadi/better-colors) ![](https://img.shields.io/badge/code--style-standard-blue) ![](https://img.shields.io/github/license/kaskadi/better-colors?color=blue)

Usage no npm install needed!

<script type="module">
  import kaskadiBetterColors from 'https://cdn.skypack.dev/@kaskadi/better-colors';
</script>

README

GitHub Actions workflows status

Build workflow status Publish workflow 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)