An easy to use, powerful and multi-functionality tools-kit library for NodeJS written entirely in JavaScript.
© Tools-Kit By BlackB1RD-Development (Author: @RealBlackB1RD). All rights reserved ©
- A Hastebin Client that can post and fetch code easily from Hastebin.
- A Logger Manager that can log a styled and colored text into the console.
- A Styles Manager that can transfer your simple text into a styled and modern one.
- A collection of easy to use and useful functions.
- Extremely configurable and debuggable.
- Well documented.
npm install BlackB1RD-Development/tools-kit --save
npm install tools-kit --save
yarn add tools-kit
Read the Documentations for more information about each method.
Class Name | Class Description |
---|---|
Hastebin Client | Post and fetch code easily from Hastebin |
Logger Manager | Log a styled and colored text into the console |
Styles Manager | Transfer your simple text into a styled and modern one (Console support only) |
Utilities | A collection of easy to use and useful functions |
With the Hastebin Client you can post and fetch code easily from Hastebin.
const { logger, hastebin } = require('tools-kit');
hastebin.post('var test = \'test\';\n\nconsole.log(test);', '.js')
.then(async postRes => {
logger.success({ tag: 'POST RES' }, postRes);
// Console > [20/02/2020 - 00:00:00 | POST RES]: HastebinObject{}
await hastebin.get(postRes.link)
.then(getRes => {
logger.success({ tag: 'GET RES' }, getRes);
// Console > [20/02/2020 - 00:00:00 | GET RES]: HastebinObject{}
})
.catch(getErr => {
logger.error({ tag: 'GET ERROR' }, getErr);
// Console > [20/02/2020 - 00:00:00 | GET ERROR]: Error: Get Error
});
})
.catch(postErr => {
logger.error({ tag: 'POST ERROR' }, postErr);
// Console > [20/02/2020 - 00:00:00 | POST ERROR]: Error: Post Error
});
With the Logger Manager you can log a styled and colored text into the console with pre made logging settings in each method.
const { logger } = require('tools-kit');
logger.log('content');
// Console > [20/02/2020 - 00:00:00 | LOG]: content
logger.important('Important log');
// Console > [20/02/2020 - 00:00:00 | IMPORTANT]: Important log
logger.success('Success log');
// Console > [20/02/2020 - 00:00:00 | SUCCESS]: Success log
logger.fatal('Fatal log');
// Console > [20/02/2020 - 00:00:00 | FATAL]: Fatal log
logger.trace('Trace log');
// Console > [20/02/2020 - 00:00:00 | TRACE]: Trace log
logger.error('Error log');
// Console > [20/02/2020 - 00:00:00 | ERROR]: Error log
logger.debug('Debug log');
// Console > [20/02/2020 - 00:00:00 | DEBUG]: Debugging log
logger.info('Information log');
// Console > [20/02/2020 - 00:00:00 | INFO]: Information log
logger.warn('Warning log');
// Console > [20/02/2020 - 00:00:00 | WARN]: Warning log
logger.figlet('FIGLET', 'LOG');
/*
Console > [20/02/2020 - 00:00:00 | FIGLET]: _____ ___ ____ _ _____ _____ _ ___ ____
Console > [20/02/2020 - 00:00:00 | FIGLET]: | ___|_ _/ ___| | | ____|_ _| | | / _ \ / ___|
Console > [20/02/2020 - 00:00:00 | FIGLET]: | |_ | | | _| | | _| | | | | | | | | | _
Console > [20/02/2020 - 00:00:00 | FIGLET]: | _| | | |_| | |___| |___ | | | |__| |_| | |_| |
Console > [20/02/2020 - 00:00:00 | FIGLET]: |_| |___\____|_____|_____| |_| |_____\___/ \____|
Console > [20/02/2020 - 00:00:00 | FIGLET]:
*/
Using custom options:
const { logger } = require('tools-kit');
// Support custom logging options and rewriting of existing methods settings
const scsSettings = {
time: 'H:mm',
tag: 'PUBLISH SUCCESS',
format: (options) => {
return `[${options.tag}]: Published ${options.content} successfully at ${options.time}`;
}
}, errSettings = {
time: 'H:mm',
tag: 'PUBLISH ERROR',
format: (options) => {
return `[${options.tag}]: Couldn't publish ${options.content} at ${options.time}`;
}
}, settings = {
tag: 'PUBLISH API',
format: (options) => {
return `[${options.tag}]: Publish API ${options.content} | Last Check: ${options.time}`;
}
}, figSettings = {
figlet: {
font: 'Ghost',
verticalLayout: 'default',
horizontalLayout: 'default'
},
log: {
name: 'figlet',
options: {
background: 'black',
color: 'red',
style: 'bold',
type: 'log',
time: 'MM/DD/YY',
tag: true,
format: (options) => {
return !options.time && !options.tag ? options.content : !options.time ? `[${options.tag}]: ${options.content}` : !options.tag ? `[${options.time}]: ${options.content}` : `[${options.time} | ${options.tag}]: ${options.content}`;
}
}
}
}, image = {
name: 'logo.png',
size: '5MB'
}, api = {
message: 'Internal Server Error',
code: '500'
};
logger.success(scsSettings, 'image named "%s" with a total size of %s', image.name, image.size);
// Console > [PUBLISH SUCCESS]: Published image named "logo.png" with a total size of 5MB successfully at 20:00
logger.error(errSettings, 'image named "%s" with a total size of %s', image.name, image.size);
// Console > [PUBLISH ERROR]: Couldn't publish image named "logo.png" with a total size of 5MB at 20:00
logger.info(settings, 'respond with %s status code and "%s" message', api.code, api.message);
// Console > [PUBLISH API]: Publish API respond with 500 status code and "Internal Server Error" message | Last Check: 20/2/2020 - 20:00:00
logger.log({ time: false }, 'log', 'no time');
// Console > [LOG]: log no time
logger.figlet(figSettings, 'Boo');
/*
Console > [20/02/2020 - 00:00:00 | FIGLET]: .-. .-')
Console > [20/02/2020 - 00:00:00 | FIGLET]: \ ( OO )
Console > [20/02/2020 - 00:00:00 | FIGLET]: ;-----.\ .-'),-----. .-'),-----.
Console > [20/02/2020 - 00:00:00 | FIGLET]: | .-. | ( OO' .-. '( OO' .-. '
Console > [20/02/2020 - 00:00:00 | FIGLET]: | '-' /_)/ | | | |/ | | | |
Console > [20/02/2020 - 00:00:00 | FIGLET]: | .-. `. \_) | |\| |\_) | |\| |
Console > [20/02/2020 - 00:00:00 | FIGLET]: | | \ | \ | | | | \ | | | |
Console > [20/02/2020 - 00:00:00 | FIGLET]: | '--' / `' '-' ' `' '-' '
Console > [20/02/2020 - 00:00:00 | FIGLET]: `------' `-----' `-----'
*/
logger.log({ time: 'MM-DD-YY' }, 'log', 'custom time format');
// Console > [02-20-2020 | LOG]: log custom time format
logger.log({ tag: false }, 'log', 'no tag');
// Console > [20/02/2020 - 00:00:00]: log no tag
logger.log({ tag: 'CUSTOM TAG' }, 'log', 'custom tag');
// Console > [20/02/2020 - 00:00:00 | CUSTOM TAG]: log custom tag
logger.log({ time: false, tag: false }, 'log', 'no tag', 'no time');
// Console > log no tag no time
logger // Support chain logging
.log({ tag: 'FIRST LOG' }, 'First content')
.log({ tag: 'SECOND LOG' }, 'Second content')
.log({ tag: 'THIRD LOG' }, 'Third content');
/*
Console > [20/02/2020 - 00:00:00 | FIRST LOG]: First content
Console > [20/02/2020 - 00:00:00 | SECOND LOG]: Second content
Console > [20/02/2020 - 00:00:00 | THIRD LOG]: Third content
*/
See more backgrounds, colors, styles & consoles types by clicking here
With the Styles Manager you can transfer your simple text into a styled and modern one.
const { logger, style } = require('tools-kit');
logger.log({ tag: 'STYLE' },
styles.bgGreen('testing %s', 'background'),
styles.red('testing %s', 'color'),
styles.underline('testing %s', 'style'),
styles.bgGreen.red.underline('testing %s', 'a style chain')
);
// Console > [20/02/2020 - 00:00:00 | STYLE]: testing background testing color testing style testing a style chain
logger.log({ tag: 'STYLE OBJECT' }, styles.stylify({ background: 'bgGreen' }, 'styled background'), 'normal background');
// Console > [20/02/2020 - 00:00:00 | STYLE OBJECT]: styled background normal background
logger.log({ tag: 'STYLE OBJECT' }, styles.stylify({ color: 'red' }, 'styled color'), 'normal color');
// Console > [20/02/2020 - 00:00:00 | STYLE OBJECT]: styled color normal color
logger.log({ tag: 'STYLE OBJECT' }, styles.stylify({ style: 'underline' }, 'styled style'), 'normal style');
// Console > [20/02/2020 - 00:00:00 | STYLE OBJECT]: styled style normal style
logger.log({ tag: 'STYLE OBJECT' }, styles.stylify({ background: 'bgGreen', color: 'red', style: 'underline' }, 'styled text'), 'normal text');
// Console > [20/02/2020 - 00:00:00 | STYLE OBJECT]: styled text normal text
logger.log({ tag: 'STYLE METHOD' }, styles.background('bgGreen', 'styled background'), 'normal style');
// Console > [20/02/2020 - 00:00:00 | STYLE METHOD]: styled background normal style
logger.log({ tag: 'STYLE METHOD' }, styles.color('red', 'styled color'), 'normal style');
// Console > [20/02/2020 - 00:00:00 | STYLE METHOD]: styled color normal style
logger.log({ tag: 'STYLE METHOD' }, styles.style('underline', 'styled style'), 'normal style');
// Console > [20/02/2020 - 00:00:00 | STYLE METHOD]: styled style normal style
logger.log({ tag: 'STYLE METHOD' }, styles.bgGreen.red.underline('styled text'), 'normal text');
// Console > [20/02/2020 - 00:00:00 | STYLE METHOD]: styled text normal text
const colors = [
styles.rgb([255, 0, 0]),
styles.hex('#ffff00'),
styles.hsv([180, 100, 100]),
styles.hsl([120, 100, 50]),
styles.hwb([240, 0, 0]),
styles.lab([35, 80, -104]),
styles.xyz([59, 28, 97]),
styles.lch([88, 90, 149]),
styles.cmyk([100, 50, 0, 0]),
styles.ansi16(12),
styles.ansi256(250),
styles.keyword('DeepSkyBlue')
];
logger.log({ tag: 'CUSTOM MAP' }, styles.map('custom map styled-text', colors), 'normal text');
// Console > [20/02/2020 - 00:00:00 | CUSTOM MAP]: custom map styled-text normal text
Using pre-made cool colors maps:
const { logger, color } = require('tools-kit');
logger.log({ tag: 'RAINBOW' }, styles.rainbow('rainbow styled-text'), 'normal text');
// Console > [20/02/2020 - 00:00:00 | RAINBOW]: rainbow styled-text normal text
logger.log({ tag: 'RANDOM' }, styles.random('random styled-text'), 'normal text');
// Console > [20/02/2020 - 00:00:00 | RANDOM]: random styled-text normal text
logger.log({ tag: 'ZEBRA' }, styles.zebra('zebra styled-text'), 'normal text');
// Console > [20/02/2020 - 00:00:00 | ZEBRA]: zebra styled-text normal text
With Tools-Kit Utilities you can use the functions that everyone uses in one simple line.
const { logger, util } = require('tools-kit');
logger.log({ tag: 'HAS?' }, util.has({}, 'name'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: false
logger.log({ tag: 'HAS?' }, util.has([], 'name'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: false
logger.log({ tag: 'HAS?' }, util.has({ name: 'test' }, 'name'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: true
logger.log({ tag: 'HAS?' }, util.has({ name: 'test' }, 'test'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: false
logger.log({ tag: 'HAS?' }, util.has({ name: 'test' }, 'name', 'test'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: true
logger.log({ tag: 'HAS?' }, util.has({ name: 'test' }, 'name', 'not test'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: false
logger.log({ tag: 'HAS?' }, util.has(['name', 'test'], 'name'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: true
logger.log({ tag: 'HAS?' }, util.has(['test', 'not test'], 'name'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: false
logger.log({ tag: 'HAS?' }, util.has([{ 'name': 'not test' }, { 'name': 'test' }], 'name'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: true
logger.log({ tag: 'HAS?' }, util.has([{ 'name': 'not test' }, { 'name': 'test' }], 'test', 'name'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: false
logger.log({ tag: 'HAS?' }, util.has([{ 'name': 'not test' }, { 'name': 'test' }], 'name', 'test'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: true
logger.log({ tag: 'ARRAY?' }, util.isArray(new Array()));
// Console > [20/02/2020 - 00:00:00 | ARRAY?]: true
logger.log({ tag: 'ARRAY?' }, util.isArray(new Object()));
// Console > [20/02/2020 - 00:00:00 | ARRAY?]: false
logger.log({ tag: 'ARRAY?' }, util.isArray([]));
// Console > [20/02/2020 - 00:00:00 | ARRAY?]: true
logger.log({ tag: 'ARRAY?' }, util.isArray({}));
// Console > [20/02/2020 - 00:00:00 | ARRAY?]: false
logger.log({ tag: 'OBJECT?' }, util.isObject(new Object()));
// Console > [20/02/2020 - 00:00:00 | OBJECT?]: true
logger.log({ tag: 'OBJECT?' }, util.isObject(new Array()));
// Console > [20/02/2020 - 00:00:00 | OBJECT?]: false
logger.log({ tag: 'OBJECT?' }, util.isObject({}));
// Console > [20/02/2020 - 00:00:00 | OBJECT?]: true
logger.log({ tag: 'OBJECT?' }, util.isObject([]));
// Console > [20/02/2020 - 00:00:00 | OBJECT?]: false
logger.log({ tag: 'RANDOM ITEM' }, util.randomItem(['cat', 'dog', 'fish']));
// Console > [20/02/2020 - 00:00:00 | RANDOM ITEM]: fish
logger.log({ tag: 'RANDOM NUMBER' }, util.randomNumber(5, 10));
// Console > [20/02/2020 - 00:00:00 | RANDOM NUMBER]: 8
logger.log({ tag: 'RANDOM NUMBER' }, util.randomNumber(5, 10, false)); // Default is true
// Console > [20/02/2020 - 00:00:00 | RANDOM NUMBER]: 9.478004123859458
bgBlack
bgGray
bgGrey
bgRed
bgGreen
bgYellow
bgBlue
bgMagenta
bgCyan
bgWhite
bgLBlack
bgLRed
bgLGreen
bgLYellow
bgLBlue
bgLMagenta
bgLCyan
bgLWhite
bgBGray
bgBGrey
bgBRed
bgBGreen
bgBYellow
bgBBlue
bgBMagenta
bgBCyan
bgBWhite
black
gray
grey
red
green
yellow
blue
magenta
cyan
white
lblack
lred
lgreen
lyellow
lblue
lmagenta
lcyan
lwhite
bgray
bgrey
bred
bgreen
byellow
bblue
bmagenta
bcyan
bwhite
reset
- Resets the current color to the default console color.bold
- Make the text bold.dim
- Emitting only a small amount of the text light.italic
- Make the text italic styled - Not widely supportedunderline
- Make the text underline styled - Not widely supportedinverse
- Inverse the background and the foreground colors.hidden
- Prints the text, but makes it invisible.strikethrough
- Puts a horizontal line through the center of the text - Not widely supported
log
- Prints tostdout
with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar toprintf(3)
(the arguments are all passed toutil.format()
).error
- Prints tostderr
with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar toprintf(3)
(the arguments are all passed toutil.format()
).trace
- Prints tostderr
the string 'Trace: ', followed by theutil.format()
formatted message and stack trace to the current position in the code.debug
- Theconsole.debug()
function is an alias forconsole.log()
.info
- Theconsole.info()
function is an alias forconsole.log()
.warn
- Theconsole.warn()
function is an alias forconsole.error()
.
Boolean
(true/false) - If to include the current time and date with the stock format when logging (Stock used moment format: DD/M/YYYY - H:mm:ss)String
- A custom moment time format to use when logging
Boolean
(true/false) - If to include the a tag when loggingString
- A custom string value to use as a tag when logging (Case sensitive)
See also the list of contributors who participated in this project.
See the Changes Log for more information about each update.
- supports-color — Detect whether a terminal supports color.
- color-convert — Plain color conversion functions.
- node-fetch — A light-weight module that brings window.fetch to Node.js.
- moment — A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.
- figlet — Creates ASCII Art from text. A full implementation of the FIGfont spec.