curly-colors

0.1.1 • Public • Published

node-curly-colors

Simplifies the working with console colors in Node.js

Installation

$ npm install curly-colors

How to include

    var cc = require('curly-colors');

Available Colors

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

Available Styles

  • bold for bold size text
  • italic for italic text
  • underline for underlined text
  • blink for blinking text
  • inverse to inverse the colors

Examples

Simple colors

    console.log(cc('<{red>red text<}>'));

Multiple colors

    console.log(cc('<{red>red text<}> <{green>green text<}>'));

Nested colors

    console.log(cc('<{red>red text <{green>green text<}> red text<}>'));
    console.log(cc('<{red>red <{green>green <{bold>bold green<}> green<}> red<}>'));

The final console output looks like this

Console Screenshot

printf-style usage

This should be used when performance is important.

    var fs = require('fs');
    var cc = require('curly-colors');
 
    var dir = './';
    var format = cc('<{yellow>%d<}> <{magenta>%s<}>');
 
    fs.readdirSync(dir).forEach(function(filename) {
        var stat = fs.lstatSync(filename);
        console.log(format, stat.size, filename);
    });

If you need you can also pass the parameters directly to curly-colors

    var result = cc("You're using <{blue>Node<}> <{magenta>%s<}>", process.version);
    console.log(result);

Readme

Keywords

none

Package Sidebar

Install

npm i curly-colors

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • muslim-idris