Socket
Socket
Sign inDemoInstall

colorred

Package Overview
Dependencies
653
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    colorred

get colors in your node.js console


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

colorred.js

Build Status version dependencies devDependencies

Please check out the roadmap for upcoming features and releases. Please open Issues to provide feedback, and check the develop branch for the latest bleeding-edge updates.

get color and style in your node.js console

Demo

Installation

npm install colorred

colors and styles!

text colors

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • gray
  • grey

bright text colors

  • brightRed
  • brightGreen
  • brightYellow
  • brightBlue
  • brightMagenta
  • brightCyan
  • brightWhite

background colors

  • bgBlack
  • bgRed
  • bgGreen
  • bgYellow
  • bgBlue
  • bgMagenta
  • bgCyan
  • bgWhite
  • bgGray
  • bgGrey

bright background colors

  • bgBrightRed
  • bgBrightGreen
  • bgBrightYellow
  • bgBrightBlue
  • bgBrightMagenta
  • bgBrightCyan
  • bgBrightWhite

styles

  • reset
  • bold
  • dim
  • italic
  • underline
  • inverse
  • hidden
  • strikethrough

extras

  • rainbow
  • zebra
  • america
  • trap
  • random

Usage

var colorred = require('colorred');

console.log(colorred.green('hello')); // outputs green text
console.log(colorred.red.underline('i like cake and pies')); // outputs red underlined text
console.log(colorred.inverse('inverse the color')); // inverses the color
console.log(colorred.rainbow('OMG Rainbows!')); // rainbow
console.log(colorred.trap('Run the trap')); // Drops the bass

Enabling/Disabling Colors

The package will auto-detect whether your terminal can use colors and enable/disable accordingly. When colors are disabled, the color functions do nothing. You can override this with a command-line flag:

node myapp.js --no-color
node myapp.js --color=false

node myapp.js --color
node myapp.js --color=true
node myapp.js --color=always

FORCE_COLOR=1 node myapp.js

Or in code:

var colorred = require('colorred');
colorred.enable();
colorred.disable();

Custom themes

var colorred = require('colorred');

// set single property
var error = ### Using string safe API.red;
error('this is red');

// set theme
colorred.setTheme({
  silly: 'rainbow',
  input: 'grey',
  verbose: 'cyan',
  prompt: 'grey',
  info: 'green',
  data: 'grey',
  help: 'cyan',
  warn: 'yellow',
  debug: 'blue',
  error: 'red'
});

// outputs red text
console.log(colorred.error("this is an error"));

// outputs yellow text
console.log(colorred.warn("this is a warning"));

Keywords

FAQs

Last updated on 03 Jun 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc