1.0.3 • Published 4 years ago

@meesvdw/coloredconsole v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

ColoredConsole

This package allows you to easily use text & background colors in the console (log, warn & debug) messages using ANSI color codes.

Installation

npm i @meesvdw/coloredconsole

Usage

First you need to require ColoredConsole into your project. I like to use the abbreviation CC because it's nice and short but you can use whatever you like.

const CC = require('@meesvdw/coloredconsole');

Text Color

    console.log(CC.red + "This text will be red " + 
                CC.green + "and this will be green.")

Background Color

    console.log(CC.BG.blue + "This background will be blue " + 
                CC.BG.yellow + "and now it's yellow :D.")

Colors

The following colors are available for text & background colors.

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

Other text effects

  • reset Will reset all applied modifications
  • bright Will brighten the text
  • dim Will dim the text
  • blink This text will blink
  • reverse Will reverse the text
  • hidden This text will be hidden
  • underscore Will put an underscore under the text

Examples

const CC = require('@meesvdw/coloredconsole');
console.log("Transaction was " + CC.green + "successful")

Result: Transaction was successful


const CC = require('@meesvdw/coloredconsole');
console.log(
    CC.red +
    'This is red! ' +
    CC.blue +
    "I'm blue, " +
    CC.blue +
    'and this is green.'
);

Result: This is red! I'm blue, and this is green.


const CC = require('@meesvdw/coloredconsole');
console.log(`I prefer ${CC.magenta} template literals...`);

Result: I prefer template literals...

1.0.3

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago