nclr
Mini NPM package with coloured log functions and more.
Contributions
Please refer to the contribution guideline.
Contributors
Documentation
Table of Contents
index
Set of functions for coloured logs.
Parameters
error
Print an error.
Parameters
data
...any Data to print
Examples
error('Something wrong happened with', new Error(this));
Returns boolean Did it happened?
info
Print an information.
Parameters
data
...any Data to print
Examples
info('Welcome John');
Returns boolean Did it happened?
dbg
Print a debug message.
Parameters
data
...any Data to print
Examples
dbg('i=', i);
Returns boolean Did it happened?
out
Print an output.
Parameters
data
...any Data to print
Examples
out(`1 + 1 = ${rpc('1 1 +')}`);
Returns boolean Did it happened?
inp
Print an input.
Parameters
data
...any Data to print
Examples
inp(name);
Returns boolean Did it happened?
warn
Print a warning.
Parameters
data
...any Data to print
Examples
warn('The following function is deprecated');
Returns boolean Did it happened?
quest
Print a question.
Parameters
data
...any Data to print
Examples
quest('What is your username?');
Returns boolean Did it happened?
succ
Print a success log.
Parameters
data
...any Data to print
Examples
succ('Achievement unlocked');
Returns boolean Did it happened?
extend
Extend the current theme.
Parameters
Examples
Using extensions as methods:
const nclr = require('nclr');
nclr.extend({
suc: ['green', 'underline'],
data: 'magenta'
});
nclr.suc('Yay!');
nclr.data(42);
Using extensions as functions:
const nclr = require('nclr');
nclr.extend({
suc: ['green', 'underline'],
data: 'magenta'
});
const { suc, data } = nclr;
suc('Yay!');
data(42);
- Throws Error Invalid extension key
clr
CLI colours.
clr
Colour/style theme for the CLI.
Type: {inp: string, out: Array<string>, info: string, error: string, warn: string, dbg: string, quest: string}
lib
Set of library functions for nclr.
log
STDOUT log.
Parameters
Examples
log('Lorem ipsum dolore sit amet');
Returns boolean Did it happened?
use
Colourise something.
Parameters
name
string Name of the log in the theme
data
...any Data
Examples
let information = use('info', 'Some info styled text');
Nesting
log('Something', use('warn', 'really ', use('info', 'cool!')));
- Throws Error Invalid name
Returns string Coloured output
restoreTheme
Restore the default fields of the theme.