Socket
Socket
Sign inDemoInstall

colorplus

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    colorplus

A painless way to color your console in node.js


Version published
Maintainers
1
Install size
517 kB
Created

Readme

Source

ColorPlus.js

A painless way to color your console in node.js.

Colorplus.js is a lazy option for those who want to print colored logs without learnning any other lib.

Colorplus in github

To Install

npm install colorplus

To Use

require("colorplus").enable();

console.log("Welcome".green, "To".bggreen, "Color".yellow, "Plus".red, "modules".bgblue.cyan);

Demo

screenshot


Examples

Setup

require("colorplus").enable();
console.log("This is ", "Color".red, "Plus".yellow, "Test");

Usage

Change the background color by prefix "bg"

console.log("Background".bggreen, "color".bgcyan, "test".bgyellow);

Use operator+ to avoid extra spaces in console.log

console.log("Background".bggreen + "color".bgcyan + "test".bgyellow);

Mix color and bgcolor

console.log(" ~ WARNING COLOR ~".bgred.yellow);

You may use colorplus.js to produce ansi color code.

var cp = require("colorplus").enable();
console.log(cp.bggreen, "Background", cp.bgcyan, "color", cp.bgyellow, "test", cp.r);
console.log(cp.bggreen + "Background" + cp.bgcyan + "color" + cp.bgyellow + "test" + cp.r);
console.log(cp.bgred, cp.yellow, " ~ WARNING COLOR ~", cp.r);

Setup without modifying String.prototype

Only when you don't want colorplus adds attributes to your String :

var cp = require("colorplus");
console.log("This is", cp.yellow, "Color", cp.red, "Plus", cp.r, "Test");

Color List

screenshot

License

Copyright(C) 2013 PG @ SENSE Lab

This project is distributed under the MIT License.

Todo list

  • (Done) I'm planning to apply the function to String.prototype. So you may use String("test").red to color it.
  • DarkColor (document not ready yet)
  • CustomCode (document not ready yet)

Feel free to improve this module by give me suggestion or pull requests.

Keywords

FAQs

Last updated on 13 Jan 2013

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