Captain.js
A toolkit for NodeJS which contains Debugger and Console Utilities.
Debugger | Console | Colors | Commands
What is Captain.js?
Captain.js is a toolkit that provides console utilities such as debugging, logging, and commands.
Console
Format console
add formats to the console that apply automatic colors, prefixes and other utilities.
const Captain = ;console = ; console;console;console;
Output:
[23:57:44] [Log] Hello
[23:57:44] [Error] This is an error
[23:57:44] [Warn] Warning! you are awesome.
Custom Console configuration
All parameters are optional.
console = "use_colors": true "debug": false "format": "§8[§d%time%§8] [%prefix%§8] §7%message%" "log_prefix": "§aLog" "warn_prefix": "§eWarn" "error_prefix": "§cError" "info_prefix": "§bInfo" "debug_prefix": "§bDebug";
Colors
Colors in console
Just do a console.log (); containing a string with color scapes.
const Captain = ;console = ; console;
Colors:
§0 = Black
§1 = Dark Blue
§2 = Dark Green
§3 = Dark Cyan
§4 = Dark Red
§5 = Dark Purple
§6 = Gold
§7 = Gray
§8 = Dark Gray
§9 = Blue
§a = Green
§b = Aqua
§c = Red
§d = Purple
§e = Yellow
§f = White
§r = Reset
Colors in console using the Enumerator
You can concatenate a string to a color using the following enumerator.
const Color = Colors; console;
Debugger
Normal debugger
It shows in the console when the function is called, which in turn contains where it is called from and in which line of code.
const Captain = ;const Debug = ; Debug;
Output:
Debug called from Object.(); || test.js:4:7
Debugger with message
It shows a message in the console when the function is called, which in turn contains where it is called from and in which line of code.
const Captain = ;const Debug = ; Debug;
Output:
This works? || test.js:4:7
Debugger with console object
const Captain = ;console = ; console;
Output:
[23:57:44] [Debug] Debug called from Object.(); || test.js:5:9
Commands
Register a command
Registers a function that will be executed when the specified command is written to the terminal.
const Captain = ;const Commander = ; Commander; Commander;
Change the command input prefix
change the text to be displayed when a command needs to be sent.
Commander;
Handle unknown commands
executes an action when trying to execute a non-existent command.
Commander