https://github.com/blackb1rd-development/tools-kit
An easy to use, powerful and multi-functionality tools-kit library for NodeJS written entirely in JavaScript.
https://github.com/blackb1rd-development/tools-kit
color color-theme custom customization hastebin hastebin-client logger logger-interface nodejs nodejs-library nodejs-modules npm npm-module npm-package utilities utility utility-library
Last synced: about 2 months ago
JSON representation
An easy to use, powerful and multi-functionality tools-kit library for NodeJS written entirely in JavaScript.
- Host: GitHub
- URL: https://github.com/blackb1rd-development/tools-kit
- Owner: BlackB1RD-Development
- License: mit
- Created: 2019-04-15T16:10:38.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-02T03:16:53.000Z (over 2 years ago)
- Last Synced: 2024-10-29T22:46:52.366Z (8 months ago)
- Topics: color, color-theme, custom, customization, hastebin, hastebin-client, logger, logger-interface, nodejs, nodejs-library, nodejs-modules, npm, npm-module, npm-package, utilities, utility, utility-library
- Language: JavaScript
- Homepage: https://tools-kit.js.org/
- Size: 1.52 MB
- Stars: 12
- Watchers: 5
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
![]()
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 ©# Features
- A [**Hastebin**][hastebin] Client that can post and fetch code easily from [**Hastebin**][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.# Install
## NPM Through GitHub
```console
npm install BlackB1RD-Development/tools-kit --save
```## NPM
```console
npm install tools-kit --save
```## Yarn
```console
yarn add tools-kit
```# Documentations
Read the [**Documentations**][documentations] for more information about each method.
# Table of Content
#### Click to jump between class examples
| Class Name | Class Description |
| --------------- | ------------------------------------------------------------------------------ |
|[**Hastebin Client**](#hastebin-client)| Post and fetch code easily from [**Hastebin**][hastebin] |
| [**Logger Manager**](#logger-manager) | Log a styled and colored text into the console |
| [**Styles Manager**](#styles-manager) | Transfer your simple text into a styled and modern one (Console support only) |
| [**Utilities**](#utilities) | A collection of easy to use and useful functions |## Hastebin Client
With the [**Hastebin**][hastebin] Client you can post and fetch code easily from [**Hastebin**][hastebin].
```javascript
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
});
```## Logger Manager
With the Logger Manager you can log a styled and colored text into the console with pre made logging settings in each method.
```javascript
const { logger } = require('tools-kit');logger.log('content');
// Console > [20/02/2020 - 00:00:00 | LOG]: contentlogger.important('Important log');
// Console > [20/02/2020 - 00:00:00 | IMPORTANT]: Important loglogger.success('Success log');
// Console > [20/02/2020 - 00:00:00 | SUCCESS]: Success loglogger.fatal('Fatal log');
// Console > [20/02/2020 - 00:00:00 | FATAL]: Fatal loglogger.trace('Trace log');
// Console > [20/02/2020 - 00:00:00 | TRACE]: Trace loglogger.error('Error log');
// Console > [20/02/2020 - 00:00:00 | ERROR]: Error loglogger.debug('Debug log');
// Console > [20/02/2020 - 00:00:00 | DEBUG]: Debugging loglogger.info('Information log');
// Console > [20/02/2020 - 00:00:00 | INFO]: Information loglogger.warn('Warning log');
// Console > [20/02/2020 - 00:00:00 | WARN]: Warning loglogger.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:
```javascript
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:00logger.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:00logger.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:00logger.log({ time: false }, 'log', 'no time');
// Console > [LOG]: log no timelogger.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 formatlogger.log({ tag: false }, 'log', 'no tag');
// Console > [20/02/2020 - 00:00:00]: log no taglogger.log({ tag: 'CUSTOM TAG' }, 'log', 'custom tag');
// Console > [20/02/2020 - 00:00:00 | CUSTOM TAG]: log custom taglogger.log({ time: false, tag: false }, 'log', 'no tag', 'no time');
// Console > log no tag no timelogger // 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**](#logger-options)
## Styles Manager
With the Styles Manager you can transfer your simple text into a styled and modern one.
```javascript
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 chainlogger.log({ tag: 'STYLE OBJECT' }, styles.stylify({ background: 'bgGreen' }, 'styled background'), 'normal background');
// Console > [20/02/2020 - 00:00:00 | STYLE OBJECT]: styled background normal backgroundlogger.log({ tag: 'STYLE OBJECT' }, styles.stylify({ color: 'red' }, 'styled color'), 'normal color');
// Console > [20/02/2020 - 00:00:00 | STYLE OBJECT]: styled color normal colorlogger.log({ tag: 'STYLE OBJECT' }, styles.stylify({ style: 'underline' }, 'styled style'), 'normal style');
// Console > [20/02/2020 - 00:00:00 | STYLE OBJECT]: styled style normal stylelogger.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 textlogger.log({ tag: 'STYLE METHOD' }, styles.background('bgGreen', 'styled background'), 'normal style');
// Console > [20/02/2020 - 00:00:00 | STYLE METHOD]: styled background normal stylelogger.log({ tag: 'STYLE METHOD' }, styles.color('red', 'styled color'), 'normal style');
// Console > [20/02/2020 - 00:00:00 | STYLE METHOD]: styled color normal stylelogger.log({ tag: 'STYLE METHOD' }, styles.style('underline', 'styled style'), 'normal style');
// Console > [20/02/2020 - 00:00:00 | STYLE METHOD]: styled style normal stylelogger.log({ tag: 'STYLE METHOD' }, styles.bgGreen.red.underline('styled text'), 'normal text');
// Console > [20/02/2020 - 00:00:00 | STYLE METHOD]: styled text normal textconst 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:
```javascript
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 textlogger.log({ tag: 'RANDOM' }, styles.random('random styled-text'), 'normal text');
// Console > [20/02/2020 - 00:00:00 | RANDOM]: random styled-text normal textlogger.log({ tag: 'ZEBRA' }, styles.zebra('zebra styled-text'), 'normal text');
// Console > [20/02/2020 - 00:00:00 | ZEBRA]: zebra styled-text normal text
```## Utilities
With Tools-Kit Utilities you can use the functions that everyone uses in one simple line.
```javascript
const { logger, util } = require('tools-kit');logger.log({ tag: 'HAS?' }, util.has({}, 'name'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: falselogger.log({ tag: 'HAS?' }, util.has([], 'name'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: falselogger.log({ tag: 'HAS?' }, util.has({ name: 'test' }, 'name'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: truelogger.log({ tag: 'HAS?' }, util.has({ name: 'test' }, 'test'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: falselogger.log({ tag: 'HAS?' }, util.has({ name: 'test' }, 'name', 'test'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: truelogger.log({ tag: 'HAS?' }, util.has({ name: 'test' }, 'name', 'not test'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: falselogger.log({ tag: 'HAS?' }, util.has(['name', 'test'], 'name'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: truelogger.log({ tag: 'HAS?' }, util.has(['test', 'not test'], 'name'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: falselogger.log({ tag: 'HAS?' }, util.has([{ 'name': 'not test' }, { 'name': 'test' }], 'name'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: truelogger.log({ tag: 'HAS?' }, util.has([{ 'name': 'not test' }, { 'name': 'test' }], 'test', 'name'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: falselogger.log({ tag: 'HAS?' }, util.has([{ 'name': 'not test' }, { 'name': 'test' }], 'name', 'test'));
// Console > [20/02/2020 - 00:00:00 | HAS?]: truelogger.log({ tag: 'ARRAY?' }, util.isArray(new Array()));
// Console > [20/02/2020 - 00:00:00 | ARRAY?]: truelogger.log({ tag: 'ARRAY?' }, util.isArray(new Object()));
// Console > [20/02/2020 - 00:00:00 | ARRAY?]: falselogger.log({ tag: 'ARRAY?' }, util.isArray([]));
// Console > [20/02/2020 - 00:00:00 | ARRAY?]: truelogger.log({ tag: 'ARRAY?' }, util.isArray({}));
// Console > [20/02/2020 - 00:00:00 | ARRAY?]: falselogger.log({ tag: 'OBJECT?' }, util.isObject(new Object()));
// Console > [20/02/2020 - 00:00:00 | OBJECT?]: truelogger.log({ tag: 'OBJECT?' }, util.isObject(new Array()));
// Console > [20/02/2020 - 00:00:00 | OBJECT?]: falselogger.log({ tag: 'OBJECT?' }, util.isObject({}));
// Console > [20/02/2020 - 00:00:00 | OBJECT?]: truelogger.log({ tag: 'OBJECT?' }, util.isObject([]));
// Console > [20/02/2020 - 00:00:00 | OBJECT?]: falselogger.log({ tag: 'RANDOM ITEM' }, util.randomItem(['cat', 'dog', 'fish']));
// Console > [20/02/2020 - 00:00:00 | RANDOM ITEM]: fishlogger.log({ tag: 'RANDOM NUMBER' }, util.randomNumber(5, 10));
// Console > [20/02/2020 - 00:00:00 | RANDOM NUMBER]: 8logger.log({ tag: 'RANDOM NUMBER' }, util.randomNumber(5, 10, false)); // Default is true
// Console > [20/02/2020 - 00:00:00 | RANDOM NUMBER]: 9.478004123859458
```## Logger Options
### options.background
- `bgBlack`
- `bgGray`
- `bgGrey`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`#### Light Backgrounds
- `bgLBlack`
- `bgLRed`
- `bgLGreen`
- `bgLYellow`
- `bgLBlue`
- `bgLMagenta`
- `bgLCyan`
- `bgLWhite`#### Bright Backgrounds
- `bgBGray`
- `bgBGrey`
- `bgBRed`
- `bgBGreen`
- `bgBYellow`
- `bgBBlue`
- `bgBMagenta`
- `bgBCyan`
- `bgBWhite`### options.colors
- `black`
- `gray`
- `grey`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`#### Light Colors
- `lblack`
- `lred`
- `lgreen`
- `lyellow`
- `lblue`
- `lmagenta`
- `lcyan`
- `lwhite`#### Bright Colors
- `bgray`
- `bgrey`
- `bred`
- `bgreen`
- `byellow`
- `bblue`
- `bmagenta`
- `bcyan`
- `bwhite`### options.style
- `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 supported**
- `underline` - Make the text _underline_ styled - **Not widely supported**
- `inverse`- 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**### options.type
- `log` - Prints to `stdout` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to `printf(3)` (the arguments are all passed to `util.format()`).
- `error` - Prints to `stderr` with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to `printf(3)` (the arguments are all passed to `util.format()`).
- `trace` - Prints to `stderr` the string 'Trace: ', followed by the `util.format()` formatted message and stack trace to the current position in the code.
- `debug`- The `console.debug()` function is an alias for `console.log()`.
- `info` - The `console.info()` function is an alias for `console.log()`.
- `warn` - The `console.warn()` function is an alias for `console.error()`.### options.time
#### The `options.time` can be either of this two
- `Boolean` (true/false) - If to include the current time and date with the stock format when logging (Stock used [**moment**][moment] format: DD/M/YYYY - H:mm:ss)
- `String` - A custom [**moment**][moment] time format to use when logging### options.tag
#### The `options.tag` can be either of this two
- `Boolean` (true/false) - If to include the a tag when logging
- `String` - A custom string value to use as a tag when logging (Case sensitive)# Author
- [**BlackB1RD**][blackb1rd]
# Maintainers
- [**BlackB1RD-Development**][blackb1rd-development]
See also the list of [**contributors**](contributors) who participated in this project.
# Changelog
See the [**Changes Log**][changelog] for more information about each update.
# License
[](https://app.fossa.io/projects/git%2Bgithub.com%2FBlackB1RD-Development%2Ftools-kit?ref=badge_large)
# Related Modules
- [**supports-color**][supports-color] — Detect whether a terminal supports color.
- [**color-convert**][color-convert] — Plain color conversion functions.
- [**node-fetch**][node-fetch] — A light-weight module that brings window.fetch to Node.js.
- [**moment**][moment] — A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.
- [**figlet**][figlet] — Creates ASCII Art from text. A full implementation of the FIGfont spec.[hastebin]:https://toptal.com/developers/hastebin/about.md
[changelog]:https://github.com/BlackB1RD-Development/tools-kit/blob/master/CHANGELOG.md
[contributors]:https://github.com/BlackB1RD-Development/tools-kit/contributors
[documentations]:https://tools-kit.js.org/api
[supports-color]: https://www.npmjs.com/package/supports-color
[color-convert]: https://www.npmjs.com/package/color-convert
[node-fetch]: https://www.npmjs.com/package/node-fetch
[moment]: https://www.npmjs.com/package/moment
[figlet]: https://www.npmjs.com/package/figlet
[blackb1rd]: https://github.com/RealBlackB1RD
[blackb1rd-development]: https://github.com/BlackB1RD-Development