2.0.1 • Published 5 years ago

node-con-color v2.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Console color

Simple script for colorize nodejs console messages.

Install

npm i node-con-color

Usage

It's simple to use this function. Put in the brackets your text and specify style as index with grid simbol before.

'#index{user text here}'

Here index means a number of styles object in config array. You can specify your own config or use default. If you want to use only first style in config, then type grid symbol without a number.

'#{apply first style}'

Default styles

indexcolorstylebackground
0whitebold-
1whiteitalic-
2rednormal-
3redbold-
4reditalic-
5greennormal-
6greenbold-
7greenitalic-
8bluenormal-
9bluebold-
10blueitalic-
11yellownormal-
12yellowbold-
13yellowitalic*-

If you want other background or combine several styles, for example 'bold' with 'italic', then use your custom styles, where define styles as array.

Available styles

colors: black, red, green, yellow, blue, magenta, cyan, white, grey styles: normal, bold, italic, underline, inversed, hidden backgrounds: none, black, red, green, yellow, blue, magenta, cyan, white

Example

const { log } = require('node-con-color');

/* default styles */
log('#{this} #1{is} #4{my} #6{colorful} #12{message}!');

/* user styles */
const styles = [
    {
        color: 'cyan',
        style: ['bold', 'italic', 'underline']
    },
    {
        color: 'red',
        style: 'bold',
        back: 'magenta'
    }
];

log('this is my #0{colorful} #1{message}!', styles);

You cant also colorize error output using ColoredError:

const { ColoredError } = require('node-con-color');

throw new ColoredError('#{This is} #12{colored} #3{error}');

linebar


Thanks for using.
Developed by Ustinov Maxim - ewclide