1.0.2 • Published 4 years ago

s1mple.js v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

npm.io

s1mple.js

Make JavaScript easier.

Hello and welcome to s1mple.js Documentation.

AreasSecond Header
JSONbaseLocal Databases Requirements, Structure, Commands, Usage
S1ncryptEncryptor Requirements, Structure, Commands, Usage

Get Started

To get started with simple.js you will need to install it as a module by the following in your console :

npm install s1mple.js

Once s1mple.js is installed you can include It on your project by typing the following in your code :

const s1mple = require('s1mple.js');
// The following is depending on what you want to include :
const JSONbase = new s1mple.JSONbase('./database/JSONbase.json'); // You'd need to specify the path
const s1ncrypt = new s1mple.s1ncrypt(3); // Specify an extra number (To encrypt Further)

s1mple.js: by yaxeldragon and luis-dev

Areas :

JSONbase

Requirements (JSONbase)

In order to use this extention you will need a JSON file with an expected input {}. You will also need to define your database.

const s1mple = require('simple.js');
const JSONbase = new s1mple.JSONbase('./database/JSONbase.json');
// JSONbase.crea...

Structure (JSONbase)

This database system is organized by row, items, values. A row contains items, and each item contains a value.

"row": {
    "item": "value"
}

Commands (JSONbase)

CommandActionID
JSONbase.addRow('Row', ['items array']);Creates a row with all itemsJB#01
JSONbase.addItem('Row', 'Item');Adds an item to a row.JB#02
JSONbase.setItem('Row', 'Item', 'value');Sets the value of an itemJB#03
JSONbase.removeRow('Row');Removes a row with all ItemsJB#04
JSONbase.removeItem('Row', 'Item');Removes an ItemJB#05
JSONbase.save();Saves all changes.JB#06
JSONbase.createBackup();Creates a backup.JB#07
JSONbase.saveBackup('Path');Saves a backup into a custom file.JB#08
JSONbase.rowExists('Row');Saves a backup into a custom file.JB#09

Usage (JSONbase)

ID: JB#01

Create a row (the base) with the following Command :

// Code (index.js)
JSONbase.addRow('s1mple.js', ['commands', 'classes', 'more stuff...']);
JSONbase.save();


// Result (JSONbase.json)
"s1mple.js": {
    "commands": "",
    "classes": "",  
    "more stuff...": ""
}
ID: JB#02

Add an item to a Row :

// Code (index.js)
JSONbase.addRow('s1mple.js', ['commands', 'classes', 'more stuff...']);
JSONbase.addItem('s1mple.js', 'newItem']);
JSONbase.save();


// Result (JSONbase.json)
"s1mple.js": {
    "commands": "",
    "classes": "",  
    "more stuff...": "",
    "newItem": ""
}
ID: JB#03

Set the value of an item inside a Row.

// Code (index.js)
JSONbase.addRow('s1mple.js', ['commands', 'classes', 'more stuff...']);
JSONbase.setItem('s1mple.js', 'classes', 'I am a class!');
JSONbase.save();


// Result (JSONbase.json)
"s1mple.js": {
    "commands": "",
    "classes": "I am a class!",  
    "more stuff...": ""
}
ID: JB#04

Removes a row. Including the items inside It.

// Code (index.js)
JSONbase.addRow('s1mple.js', ['commands', 'classes', 'more stuff...']);
JSONbase.removeRow('s1mple.js');
JSONbase.save();


// Result (JSONbase.json)
{}
ID: JB#05

Removes an Item inside a Row.

// Code (index.js)
JSONbase.addRow('s1mple.js', ['commands', 'classes', 'more stuff...']);
JSONbase.removeItem('s1mple.js', 'classes', 'I am a class!');
JSONbase.save();


// Result (JSONbase.json)
"s1mple.js": {
    "commands": "",
    "more stuff...": ""
}
ID: JB#06

Saves all stored locally on the Database.

// Code (index.js)
JSONbase.addRow('s1mple.js', ['commands', 'classes', 'more stuff...']);
JSONbase.save(); // Saves all changes done to JSONbase.

// Result (JSONbase.json)
"s1mple.js": {
    "commands": "",
    "classes": "",  
    "more stuff...": ""
}
ID: JB#07, and JB#08

Creates a Backup.

// Code (index.js)
JSONbase.addRow('s1mple.js', ['commands', 'classes', 'more stuff...']);
JSONbase.save();
JSONbase.createBackup();
JSONbase.saveBackup('./backups/myBackup.json');

// Result (JSONbase.json)
"s1mple.js": {
    "commands": "",
    "classes": "",  
    "more stuff...": ""
}

// Backup (myBackup.json)
"s1mple.js": {
    "commands": "",
    "classes": "",  
    "more stuff...": ""
}
ID: JB#09

Checks if a row exists and returns a true or false (can be used in if's statements)

// Code (index.js)
JSONbase.addRow('s1mple.js', ['commands', 'classes', 'more stuff...']); // CREATES a Row.
if (JSONbase.rowExists('commands')) { // If 'commands' row exits

    JSONbase.newItem('s1mple.js', 'Means It exists!'); // Creates a Row.
    JSONbase.save();
} else {
    JSONbase.addRow('s1mple.js', ['commands', 'classes', 'more stuff...']);
}
// PD : If it exists

// Result (JSONbase.json)
"s1mple.js": {
    "commands": "",
    "classes": "",  
    "more stuff...": ""
}

// Backup (myBackup.json)
"s1mple.js": {
    "commands": "",
    "classes": "",  
    "more stuff...": ""
}

S1ncrypt

Requirements (S1ncrypt)

In order to use this extention you will need to insert the following in your code :

const s1ncrypt = new s1mple.s1ncrypt(3);
// You can plug any NUMBER for 3, It's an extra layer of encryption.

Structure (S1ncrypt)

(S1mple.js Developers Secret)

Commands (S1ncrypt)

CommandActionID
JSONbase.encrypt('string', 'hexa-char');Creates a row with all itemss1yt#01

Usage (S1ncrypt)

ID: s1yt#01

Returns an encrypted Text :

let encrypted = s1ncrypt.encrypt('MyString', 'hexa-char');
        // Don't change the method (hexa-char). That's the only one currently
console.log(`'MyString': '${encrypted}'`);

// Console Output :
> 'MyString': 'M37My138yS53St125tr120ri96in109ng90g'

Versions

1.0.2 : Made JSONbase find file route easier, Check if Items exists, and auto-fix an unexpected JSON input. Also Introducing s1ncrypt to be able to encrypt strings with only two commands.