Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clorox

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clorox

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

  • 2.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
711
decreased by-88.08%
Maintainers
1
Weekly downloads
 
Created
Source

Clorox

Codecov

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 } = require("clorox")

Write with color.

console.log(x.red("Bonjour!"))

Chain expressions.

console.log(x.red.underline("Hello") + x.blue.bold("World") + "!")

Compose a color expression using template literals.

console.log(`
  Oil: ${x.bgBlack.white(42)}
  Gold: ${x.yellow(150)}
  Lumber: ${x.green(10000)}
`)

Nest expressions to reuse styles.

console.log(`Normal ${x.bold(`Bold ${x.blue("Bold/Blue")} Bold`)} Normal`)

Use string substitution for easier formatting.

console.log(x.green("Total: $%f"), 1.99)

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 } = require("clorox")

console.log(`${STYLES.red.open}Red${STYLES.red.close}`)

Available Styles

ColorsBackground ColorsModifiers
blackbgBlackdim
redbgRedbold
greenbgGreenhidden
yellowbgYellowitalic
bluebgBlueunderline
magentabgMagentainverse
cyanbgCyanstrikethrough
whitebgWhitereset
gray

License

Clorox is MIT licensed. See LICENSE.

Keywords

FAQs

Package last updated on 13 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc