JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 17785
  • Score
    100M100P100Q2152F
  • License MIT

Node.js library for colorizing text using ANSI escape sequences.

Package Exports

  • clorox

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (clorox) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Clorox

Codecov

Clorox is a Node.js library for colorizing text using ANSI escape sequences.

  • Eco-friendly: We don't extend the String.prototype.
  • Concentrated: Zero dependencies. Clorox is not broken into a dozen modules that only work together.
  • Non-toxic: Auto-detect color support without polluting your terminal with unrecognized escape codes.

Installation

npm i clorox

Usage

const c = require("clorox")

Examples

Compose a color expression.

console.log(`${
  c.red.bold("What's").newLine.inverse("up?")
}`)

Concatenate expressions.

console.log(
  c.red.bold("What's") + "\n" + c.red.inverse("up?")
)

Nest expressions to reuse styles.

console.log(`${
  c.bold(c.red("Bold & Red"))
}`)

Create your own styles.

const Styles = {
  em(s) {
    return c.bgBlack.yellow(s)
  }
}

console.log(`${
  c(Styles.em("A funny")).bold(" joke.")
}`)

Styles

Colors Background Colors Modifiers Other
black bgBlack dim newLine
red bgRed bold tab
green bgGreen hidden reset
yellow bgYellow italic
blue bgBlue underline
magenta bgMagenta inverse
cyan bgCyan strikethrough
white bgWhite
gray

License

Clorox is MIT licensed. See LICENSE.