Collection of tools and data for speed up your coding and enhance code
Can be used in express, vue, react, gsap, mongoose and any web app
Modules
- gsap
- from
- anime
- scrollTrigger
- color
- colors
- rgbToHex
- randomHex
- console
- bcrypt
- hash
- compare
- crypto
- encrypt
- decrypt
- expressValidation
- map
- keys
- middleware
- cors
- hsts
- sign
- logger
- number
- generateRandomDigitsInRangeOf
- generateRandomDigits
- string
- capString
- reverseString
- hasWhiteSpaces
- isLatinWithDigits
- isLatin
- isPersianWithDigits
- isPersian
- removeWhiteSpaces
- assertString
- validate
- isSlug
- isUrl
- isStrongPassword
- isSimplePassword
- isDiscordUser
- isEmail
- isEmoji
- isDate
- isTime
- isIP
- isBase64
- isJWT
- array
- arrayIsEmpty
- bubbleSort
- object
- objectIsEmpty
- merge
- utils
- sleep
- log
- celsiusToFahrenheit
- fahrenheitToCelsius
- currency
- format
- prefix
- postfix
- logger
- region
- iran
- checkNationalCode
- checkMobileNumber
- normalizeMobileNumber
- nameOptimizer
- need help to complete
- iran
- countries
- country
- state
- city
- iranCities
- nav
- pagePagination
- itemPagination
- rs
- sr
- badwards
Usage/Examples
Color
const { color } = requier('swiftly-tools');
const colors = color.colors(); // return list of colors with name
color.rgbTohex(255,255,255); // return hex code
color.randomHex(); // return random hex code
console.log(color.console("Hello ", "fgRed"),color.console("World!", "bgRed"))
bcrypt
const { bcrypt } = requier('swiftly-tools');
const salt = 10
const hashed = bcrypt.hash("hello", salt) // return hashed string
const compare = bcrypt.compare("hello", hashed) // if equal return true
crypto
const { crypto } = requier('swiftly-tools');
const secret = "12345678"
const algo = 'aes-256-cbc' // optional
const hashed = crypto.encrypt(secret, "hello", algo) // return hashed string
crypto.decrypt(secret, hashed, algo) // return normal string
expressValidation
const ev = requier('swiftly-tools').expressValidation;
const { validationResult } = require('express-validator')
ev.map(validationResult) // return
/**
{
"validation": {
"fullName": {
"value": null,
"msg": "نام را وارد کنید",
"param": "fullName",
"location": "body"
}
}
}
*/
ev.keys(validationResult) // return { fullName: "نام را وارد کنید" }
middleware
const { middleware } = requier('swiftly-tools');
const express = require("express");
const app = express();
app.use(middleware.cors()) // set cors *
app.use(middleware.hsts()) // set Strict-Transport-Security header
app.use(middleware.sign("Swift")) // Set your name in Author header
In Progress …