const utils = require('@mr_fozan/utils.js');
Contents:
Timestamp is a data type for storing date and time. The data is stored as the number of milliseconds elapsed since the beginning of the "Unix epoch". The range of values is: 1970-01-01 00:00:00 - 2038-12-31 00:00:00.
const timestamp = utils.date.timestamp(); // 1675871841130
Simple millisecond calculator.
- s - seconds
- m - minutes
- h - hours
- d - days
const calculate = utils.date.inmls(10, "d"); // 864000000
This method will help to get the date and time timestamp
const timestamp = utils.date.timestamp();
const date_time = utils.date.getDate(timestamp); // [ '08.02.2023', ' 19:01:06' ]
This method helps to get an expanded time using milliseconds, e.g: 3600000 => 1 ч.
The result can be written in two languages:
- ru - Russian language
- en - English language
const unixTimeFull = utils.date.unixTime({ time: 1000, lang: "ru" }); // 1 сек.
const unixTimeShort = utils.date.unixTime({ time: 1000, type: "short" }); // 00:00:00
Contents:
const apple = utils.declination.number({
number: 101,
first: "Яблок",
second: "Яблоко",
third: "Яблока"
}); // Яблоко
Contents:
const division = utils.number.division(1000, "."); // 1.000
const suffix = utils.number.suffix(1000); // 1K
const random = utils.number.random(1, 1000); // min, max
const random2 = utils.number.random(1000); // max
const percent = utils.number.percent(1, 100); // 1
const even = utils.number.even("A"); // undefined
const even2 = utils.number.even(123); // false
const even3 = utils.number.even(12346); // true
Contents:
const url = utils.parse.url("https://github.com/Fozan-Developer/utils.js");
Contents:
- Validation Base64
- Validating a credit card number
- Validation Date
- Validation Email
- File extension
- Validation IPv4
- Validation ISBN
- isNumber
- Validation Number
- Validation URL
- Validation Username
- Validation Zip-Code
const argument = "base64";
const base64 = utils.regexp.base64(argument); // false
const sucs = utils.regexp.card("1111111111111111"); // true
const fail = utils.regexp.card("12345"); // false
const date1 = utils.regexp.date("29-02-2000"); // true
const date2 = utils.regexp.date("29-02-2001"); // false
const email = utils.regexp.email("test@gmail.com"); // true
const file_name = "index.js";
const file = utils.regexp.file(file_name); // js
const ipv4 = utils.regexp.ipv4("192.0.2.235");
const isbn1 = utils.regexp.isbn("ISBN 9781106998966"); // true
const isbn2 = utils.regexp.isbn("1106998966"); // true
const isbn3 = utils.regexp.isbn("110699896x"); // true
Check for a number
const isNumber1 = utils.regexp.isNumber("123"); // true
const isNumber2 = utils.regexp.isNumber("123x"); // false
Validate phone number
const number1 = utils.regexp.isNumber("(121) 123-1234"); // true
const number2 = utils.regexp.isNumber("+1 123-123-1234"); // true
const number3 = utils.regexp.isNumber("+1 123-123-12-12"); // false
const url1 = utils.regexp.url("https://github.com/"); // true
const url2 = utils.regexp.url("abc"); // false
Validation of username by form:
- Length from 3 to 16 characters
- Digits
- Small letters
- Characters - and _
const username1 = utils.regexp.username("admin_owner-1"); // true
const username2 = utils.regexp.username("Admin_Owner-1"); // false
const rus = utils.regexp.zip_code("RUS", "537414"); // true
const usa = utils.regexp.zip_code("USA", "98765-4321"); // true
Contents:
There are three kinds of events:
- sucs - Successful
- fail - Not successful
- loading - Loading
const sucs = utils.symbol.actions("sucs"); // ✅
const fail = utils.symbol.actions("fail"); // ✖️
const loading = utils.symbol.actions("loading"); // 🔄
Process-bar types:
- stars - returns the process-bar as stars (★★★★★)
- squares - returns process-bar as squares (▪▪▪▪▪▪▪▪▪▪)
const stars = utils.symbol.bar({ type: "stars" current: 50, maximum: 100 }); // ★★✯☆☆
const squares = utils.symbol.bar({ type: "squares" current: 10, maximum: 100 }); // ▪▫▫▫▫▫▫▫▫▫
Returns a number in the form of characters
const number = utils.symbol.number(123); // 1️⃣2️⃣3️⃣
Method helps to get a random element from an array. Use the String data type in the array to work correctly.
const pick = utils.symbol.pick(["Java", "JavaScript", "Node.JS"]); // Node.JS