nodelly
v0.2.1
Published
Helping Node.js developers to build better applications with less code.
Maintainers
Readme
Nodelly v1pr2B
Nodelly is a lightweight and efficient Node.js library designed to simplify your development process. It provides a set of utilities and tools for common tasks to enhance productivity.
This is an beta pre-release of the library, please be aware that unexpected bugs or errors may occure. If you find any please report them, thanks for your help! We're tring our best, please be patient!
Features
- Easy to Use: Easy to understand, making usage easier for beginners.
- Lightweight: Minimal dependencies for faster performance.
- Fast Usage: Use what fits you the best easily without memorating a lot of repetitive code.
Modules and Functions
- Regexes: Predefined regexes to save time. Regexes like: Latin Letters, Symbols, Numbers, IP stuff, Password, Time, Phone Number and much more!
- Sorting Algorithms: Never wanted to memorate this codes? No worries, here you find 8 types of sorting algorithms, even an alphanumerical one for your array!
- Variable Checker: Always wanted to check if the user input was the right one, but you always forgot how? No worries, we got you. Check a lot for a lot of types, you can even check if an String, Object, Array or Matrix is empty!
- Data Validator: So will it fit for a username or not? Let's find out using the Validator module! Check for IP's, Username, Passwords and lots of things just with a few words!
- Managers:
- String Manager: Capitalize, search, change casing and do a lot of more things faster!
- Array Manager: Shuffle, sort, delete multiple items much much faster!
- Randomizer Manager: Randomize string and numbers easier!
- File Manager: Is 'fs' too hard for you? No worries, we got you!
- Config Manager: (dot)ENV got a little bit too old, let's upgrade!
Installation
Install Nodelly via npm:
npm install nodellyUsage
Here's a quick example to get started:
// Importing the nodelly module
const nodelly = require('nodelly');
// Define the modules to be used
const regexes = nodelly.Regexes;
const sort = nodelly.Sort;
const checker = nodelly.Checker;
const manager = nodelly.Manager;
const validator = nodelly.Validator;
/*
You can define the manager module's functions separatly too!
*/
const string = manager.String;
const array = manager.Array;
const randomizer = manager.Randomizer;
// Example usage of the Regexes module
if(regexes.hex.test('0x1234')) {
console.log('Hex regex test passed!');
}
else {
console.log('Hex regex test failed!');
}
if(regexes.hex.test('1234')) {
console.log('Hex regex test passed!');
}
else {
console.log('Hex regex test failed!');
}
/*Output:
Hex regex test passed!
Hex regex test failed!
*/
// Example usage of the Manager module
console.log(manager.String.capitalize('hello world'));
console.log(string.searchFor('hello world', 'hello'));
console.log(randomizer.randomString(7));
/*Example Output:
Hello world
true
AQGPv2e
*/
// Example usage of the Sort module
let arr1 = [0, 3, 9, 8, 4];
console.log(sort.bubbleSort(arr1));
let arr2 = ["Coding", "30", "8", "boolean", "Array", "Decimal", "1", "64"];
console.log(sort.aplhanumericSort(arr2));
/*
[0, 3, 4, 8, 9]
["1", "8", "30", "64", "Array", "Boolean", "Coding", "Decimal"]
*/
// Example usage of the Checker module
let str = "Hello World!";
let reg = /hello/i;
let arr = [1, 2, 3, 4, 5];
console.log(str + " is", checker.isString(str) ? "" : "not", "an string."); // true
console.log(arr + " is", checker.isString(arr) ? "" : "not", "an string."); // false
console.log(reg + " is", checker.isRegex(reg) ? "" : "not", "an regex."); // true
console.log(str + " is", checker.isRegex(str) ? "" : "not", "an regex."); // false
console.log(arr + " is", checker.isArray(arr) ? "" : "not", "an array."); // true
console.log(reg + " is", checker.isArray(reg) ? "" : "not", "an array."); // false
// Example usage of the Validator module
const email = "[email protected]";
console.log(`Is "${email}" a valid email?`, validator.isValidEmail(email)); // false
const password = "StrongP@ssw0rd!";
console.log(`Is "${password}" a valid password?`, validator.isValidPassword(password)); // true
const username = "us!-er_na@#me123";
console.log(`Is "${username}" a valid username?`, validator.isValidUsername(username)); // false
// Example usage of the File manager
const file = manager.File;
file.write('example.txt', 'Hello, Nodelly!');
const content = file.read('example.txt');
console.log(content); // Output: Hello, Nodelly!
console.log(file.exists('example.txt')); // Output: true
file.delete('example.txt');
// Example usage of the Config manager
const config = manager.Config;
const defaultConfig = { app: { name: 'Nodelly', version: '0.1.2' }, debug: true };
config.create('config.yml', defaultConfig);
const conf = config.read('config.yml');
console.log(conf.app.name); // Output: Nodelly
console.log(config.get('config.yml', 'app.version')); // Output: 0.1.2
config.set('config.yml', 'debug', false);
config.delete('config.yml', 'app.version');Error Types
See more info in: ./lib/errors/index.js
- NullVariable: 404 - Indicates that the given variable is an instance of NULL or UNDEFINED.
- InvalidType: 417 - Indicates that the given variable is cannot be used in the function properly because of it's declaration type.
- InvalidVariable: 424 - Indicates that the given variable is not declared properly nor defined properly and can let you to other issues and performance loss.
- InvalidPath: 425 - Indicates that the given path is not found or cannot be modified because the lack of permissions.
Lastest Update
- Publication Date: 25/10/28
- Version change: 0.1.2 Pre-Release Beta 1 (v2pr1B) -> 0.2.1 Pre-Release Beta 2 (v1pr2B)
The update contained:
- !!!NEW!!! Added Config and File manager for better and easier file handling in your project.
- Separated Managers in their own files for better code understanding.
- Added a new error type.
Feedback
Want to tell us about bugs or how to improve this library? Send us a form right now! (Click here.)
Contributing
Contributions are welcome! Contact me if you have any idea on how to improve this library!
License
This project is unlicensed meaning free for usage, updating or adding external features if needed.
