Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leslitech/lesli-js
JavaScript utilities for JavaScript applications
https://github.com/leslitech/lesli-js
Last synced: about 1 month ago
JSON representation
JavaScript utilities for JavaScript applications
- Host: GitHub
- URL: https://github.com/leslitech/lesli-js
- Owner: LesliTech
- License: other
- Created: 2021-10-19T01:59:00.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-04-20T14:05:01.000Z (over 2 years ago)
- Last Synced: 2023-03-03T21:02:00.241Z (almost 2 years ago)
- Language: JavaScript
- Size: 76.2 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
JavaScript utilities for JavaScript applications
Version 0.5.0 :octocat:
## Table of Contents
- [Application Structure](#application-structure)
- [Installation](#installation)
- [Get Started](#get-started)
- [Usage](#usage)
- [LesliJS Debug](#leslijs-debug)
- [Debug for NodeJS](#debug-for-nodejs)
- [Debug for Browsers](#debug-for-browsers)
- [LesliJS Color](#leslijs-color)
- [Palette](#palette)
- [Graph](#graph)
- [License](#license)### Application Structure
--------
```text
lesli-js
└── src/
├── debug/
│ ├── browser.js
│ ├── nodejs.js
│ ├── utils.js
│ └── index.js
└── colors/
├── palette.js
├── graphs.js
└── index.js```
### Installation
LesliJS is available in the Node Package Manager, so, you can install it through [npm](https://www.npmjs.com/package/lesli-js).
--------
```console
npm install lesli-js --save
```### Get Started
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_
```js
// Import LesliJS
const LesliJS = require("lesli-js")
```_ECMAScript 6_
```js
import LesliJS from "lesli-js"
```### Usage
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.--------
#### LesliJS Debug
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.--------
#### Debug for Node.js
See the following example of a simple message.
```js
// 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.
```console
[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.**
```js
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.
![image](https://user-images.githubusercontent.com/62123356/146724702-42f19da9-8cbc-49f6-9a74-9da6c5cf677c.png)
--------
```js
const { debug } = require("lesli-js")debug.hr() // just a separator line
```Output.
```console
-·- -·- -·- -·- -·- -·- -·- -·- -·- -·-
```--------
If you just want to build the message structure, use the method `build`, which one returns a string.
```js
const { debug } = require("lesli-js")const message = debug.nodejs.build("Message", "Module", "Level")
console.log(message)
```Output.
```console
[12/17 18:46] [LEVEL] (Module) - Message
```--------
```js
// make Lesli debug messages globally in your app
window.debug = leslijs.debugconsole.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")
```#### Debug for Browsers
LesliJS Debug Browser also offers pretty nice console messages for browsers, which ones are the same methods as the ones of [Debug for nodejs](#debug-for-nodejs), `log`, `info`, `error`, `fatal`... but with the main difference that are useful for Fronted web applications.--------
See the following examples.
```js
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.
![image](https://user-images.githubusercontent.com/62123356/146725103-8082abc7-e1e0-41ef-8074-c30009e4e7c1.png)
These methods have the same structure as the ones of [Debug for nodejs](#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.
```js
import { debug } from "lesli-js"debug.browser.message("Title", ["Messages1", "Message2"], "More information")
```The output in the browser console should look like this.
![image](https://user-images.githubusercontent.com/62123356/146725207-94ba5029-62b4-43f4-b3f2-844f7cd3e31f.png)
Method specification.
```debug.browser.message(title: string, messages: array or a simple string, more_information?: string)```
#### LesliJS Color
Provides colors (as string or JSON) based on the Lesli color palette, which ones are in hex code format.--------
#### Palette
The LesliJS Color Palette has several methods to serve colors depending on the one you are interested in.See the following examples.
```js
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 |#### Graph
The LesliJS Color Graph provides the graph of a color palette given, and returns an array with all colors.--------
See the following examples.
```js
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 |### License
------
Software developed in [Guatemala](http://visitguatemala.com/) distributed under the *General Public License v 3.0* you can read the full license [here](http://www.gnu.org/licenses/gpl-3.0.html)