New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

conscolors

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conscolors

Console output with colors and predefined text so you can easily trace what are you logging. To be used with Node

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

consColors

Yet another npm package that prints colors in your console :tada:

But... the idea behind this module it's not that you can get crazy and print 1000s of different styles, this module gives you the ability to print log, warn or error messages to the stdout with a predefined message.

Have you found yourself doing something like this?

function Animal( name ) {
  this.name = name;
  .....
}

const lion = new Animal( 'Simba' );
const cat = new Animal( 'Garfield' );
const dog = new Animal( 'Scooby-Doo' );

console.log('lion:', lion);
console.log('cat:', cat);
console.log('dog:',dog);

The idea of this module is that by creating an instance of the logger you can omit the reference to the variable that you are trying to log the info.

const lionLogger = consColors( 'lion' );

lionLogger.log( 'hakuna matata' ); // lion: hakuna matata

How to use this package

The setup is quite easy, require the module and pass an object with 2 possible properties:

[type][string] required

Text to be logged any time that you call a method on the created instance.

[invert][boolean]

Use this option if you want to invert the color, i.e. rather than having the text in different colors force to have the background in different colors.

See examples and picture to have a better idea about the possible outputs.

const consColors = require( 'consColors' );

const consColorNormal = consColors({type: 'consColors'});
const consColorInvert = consColors({type: 'consColors', invert: true});

consColorNormal.log( 'This is a success example' );
consColorNormal.warn( 'This is a warn example' );
consColorNormal.error( 'This is an error example' );

consColorInvert.log( 'This is a success example with invert option' );
consColorInvert.warn( 'This is a warn example with invert option' );
consColorInvert.error( 'This is an error example with invert option' );
demo image with examples

Keywords

ansi

FAQs

Package last updated on 08 Dec 2017

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