Clorox
Clorox is a Node.js library for colorizing text using ANSI escape sequences.
- All-in-one — Not broken into a dozen modules that only work together.
- Eco-friendly — No modifications were made to the String.prototype in the making of this package.
- It Just Works™ — Auto-detects color support and degrades gracefully without contaminating your terminal with broken escape codes.
Installation
npm i clorox
Usage
const Clorox: x =
Write with color.
console
Chain expressions.
console
Compose a color expression using template literals.
console
Nest expressions to reuse styles.
console
Use string substitution for easier formatting.
console
Styles
Clorox exports ANSI escape codes which you can use for manually styling console output. They can be useful for testing your actual output matches the expected output.
Each style has an open
, close
and strip
property. The strip
property is useful for removing the previously closed escape code within a nested expression.
const STYLES = console
Available Styles
Colors | Background Colors | Modifiers |
---|---|---|
black | bgBlack | dim |
red | bgRed | bold |
green | bgGreen | hidden |
yellow | bgYellow | italic |
blue | bgBlue | underline |
magenta | bgMagenta | inverse |
cyan | bgCyan | |
white | bgWhite | reset |
gray |
License
Clorox is MIT licensed. See LICENSE.