Version 0.5.0
lesli-js
└── src/
├── debug/
│ ├── browser.js
│ ├── nodejs.js
│ ├── utils.js
│ └── index.js
└── colors/
├── palette.js
├── graphs.js
└── index.js
LesliJS is available in the Node Package Manager, so, you can install it through npm.
npm install lesli-js --save
First of all, you have to require the library in your JavaScript project. There are many ways to do this, it depends in the ECMAScript version your are using.
ECMAScript 5
// Import LesliJS
const LesliJS = require("lesli-js")
ECMAScript 6
import LesliJS from "lesli-js"
LesliJS provides a bundle of features that are useful for JavaScript applications, either for Fronted or Backend. These features are related with debugging and the color management of your app. Use them as you need.
You can use LesliJS debug in the way for printing messages in your terminal. Those messages have been customized according with type of message, log
, info
, error
, fatal
... The main difference is in the color that are printed.
See the following example of a simple message.
// Import LesliJS debug directly
const { debug } = require("lesli-js")
// This is a simple message using LesliJS debug
debug.nodejs.log("Simple Message", "cheese")
debug.nodejs.
<type_of_message>(message: string, module?: string)
The output should look like this.
[12/17 17:47] [LOG] (cheese) - Simple message
All the available debug messages in LesliJS debug have the following structure.
[
datetime ]
[
type of message ]
(
module)
-
your message
- datetime is generated by LesliJS debug.
- type of message method is declared when the user logs a new message (debug.nodejs.
log
, debug.nodejs.error
, ...). - module is optional, if you don't declare it, won't appear in the terminal, on the contrary you have to give a string.
- your message is required when the user logs a new message and we recommend to give a string.
See all types of messages available.
const { debug } = require("lesli-js")
// print pretty yet useful debug messages
debug.nodejs.log("Simple message")
debug.nodejs.msg("Standard message")
debug.nodejs.info("Informative message")
debug.nodejs.warn("Warning message")
debug.nodejs.error("Error message")
debug.nodejs.fatal("Fatal error message")
The output should look like this.
const { debug } = require("lesli-js")
debug.hr() // just a separator line
Output.
-·- -·- -·- -·- -·- -·- -·- -·- -·- -·-
If you just want to build the message structure, use the method build
, which one returns a string.
const { debug } = require("lesli-js")
const message = debug.nodejs.build("Message", "Module", "Level")
console.log(message)
Output.
[12/17 18:46] [LEVEL] (Module) - Message
// make Lesli debug messages globally in your app
window.debug = leslijs.debug
console.debug.log("Simple message")
console.debug.msg("Standard message")
console.debug.info("Informative message")
console.debug.warn("Warning message")
console.debug.error("Error message")
console.debug.fatal("Fatal error message")
LesliJS Debug Browser also offers pretty nice console messages for browsers, which ones are the same methods as the ones of Debug for nodejs, log
, info
, error
, fatal
... but with the main difference that are useful for Fronted web applications.
See the following examples.
import { debug } from "lesli-js"
debug.browser.log("Standard message", "Module") // Standard log message
debug.browser.msg("Simple message", "Module") // Simple message
debug.browser.info("Informative message", "Module") // Informative message
debug.browser.warn("Warning message", "Module") // Warning message
debug.browser.error("Error message", "Module") // Error message
debug.browser.fatal("Fatal message", "Module") // Fatal message
The output in the browser console should look like this.
These methods have the same structure as the ones of Debug for nodejs.
debug.browser.
<type_of_message>(message: string, module?: string)
The message shown in the browser console.
[
datetime ]
[
type of message ]
(
module)
-
your message
- datetime is generated by LesliJS debug.
- type of message method is declared when the user logs a new message (debug.nodejs.
log
, debug.nodejs.error
, ...). - module is optional, if you don't declare it, won't appear in the terminal, on the contrary you have to give a string.
- your message is required when the user logs a new message and we recommend to give a string.
LesliJS Debug Browser also has another method called message
, which logs a dedicated message and receives the params title
, message
, more_information
, where the only one required is the more_information
param.
See the following example.
import { debug } from "lesli-js"
debug.browser.message("Title", ["Messages1", "Message2"], "More information")
The output in the browser console should look like this.
Method specification.
debug.browser.message(title: string, messages: array or a simple string, more_information?: string)
Provides colors (as string or JSON) based on the Lesli color palette, which ones are in hex code format.
The LesliJS Color Palette has several methods to serve colors depending on the one you are interested in.
See the following examples.
import { color } from "lesli-js"
// Work with the entire color palette as JSON
color.pallete
// Get palette of a specific color as JSON
color.pallete.blue
// Get standard colors (returns a string with hex code format)
// By default the variant used is 500 in all colors
color.blue()
// Get color with a specific variant
// Returns a string with hex code format
color.blue(500)
// Or you can get the color directly from the palette
// Returns a string with hex code format
color.palette.blue['500']
All available colors.
Colors |
---|
bubble |
grape |
lime |
orange |
berry |
cocoa |
banana |
slate |
mint |
black |
silver |
solid |
All available variant of colors.
Variants |
---|
100 |
300 |
500 |
700 |
900 |
The LesliJS Color Graph provides the graph of a color palette given, and returns an array with all colors.
See the following examples.
import { color } from "lesli-js"
// Get the graph of the blue color
// Returns an array with colors in hex code format
color.graph("blue")
All available graphs.
Graphs |
---|
blue |
Software developed in Guatemala distributed under the General Public License v 3.0 you can read the full license here