@fjrodafo/colors v0.0.5
Install it!
npm i @fjrodafo/colorsRun it!
// Import the module
import cf from "@fjrodafo/colors"// It will display a formatted color message
console.log(
cf.italic(`I see a ${cf.bgRed("red")} car and I ${cf.bold("want")} it painted ${cf.black("black")}.`)
)Usage
This library provides an object which includes a variety of text coloring and formatting functions.
The object includes following coloring functions: black, red, green, yellow, blue, magenta, cyan, white, gray.
The object also includes following background color modifier functions: bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite.
Besides colors, the object includes following formatting functions: dim, bold, hidden, italic, underline, strikethrough, reset, inverse.
Additional utilities
The library provides additional utilities to ensure the best results for the task:
isColorSupported- boolean, explicitly tells whether or not the colors or formatting appear on the screen.if (cf.isColorSupported) { console.log("Yay! This script can use colors and formatters") }createColors(enabled)- a function that returns a new API object with manually defined color support configuration.let { red, bgWhite } = cf.createColors(options.enableColors)
Links
Full repository on github/gitlab.
Visit the npm package website here.