Dot Functions Utils
How to use
Install
npm i dot_functions_utils
or
yarn add dot_functions_utils
Dates
require('dot_functions_utils');
var dateNow = new Date;
dateNow.getWeekDay();
dateNow.getWeekDay('eng');
dateNow.getWeekDay('es');
dateNow.getWeekDay('pt-br');
dateNow.getFirstDay();
dateNow.getLastDay();
dateNow.getWeekEnd();
dateNow.getWeekBegin();
dateNow.nextDay(5);
dateNow.backDay(5);
dateNow.format();
dateNow.format('yyyy-mm-dd');
dateNow.format('dd-mm-yyyy');
dateNow.format('dd/mm/yyyy');
dateNow.format('yyyy/mm/dd');
dateNow.format('dd/mm/yyyy - hh:mm:ss');
dateNow.nextMonth(1);
dateNow.previousMonth(1);
dateNow.nextYear(1);
dateNow.previousYear(1);
dateNow.getMonthName();
dateNow.getMonthName('eng');
dateNow.getMonthName('es');
dateNow.getMonthName('pt-br');
dateNow.getDayOfYear();
dateNow.log();
dateNow.log("Date");
dateNow = new Date(2020, 6, 18, 0, 18, 35);
dateNow.toFormat("Day DD, MMMM of YYYY");
dateNow.toFormat("Day DD, MMMM de YYYY", 'pt-br');
Arrays
const { waitFor } = require('dot_functions_utils');
let list = [1, 2, 3, 4];
let myList = [2, 3, 4];
list.getLastElement();
list.getFirstElement();
list.getMiddleElement();
myList.getMiddleElement();
myList.log();
myList.log("Array");
myList.forEachSync(
async (elemente, index, array) => {
await waitFor(1);
console.log(elemente);
}
);
Strings
require('dot_functions_utils');
let myFirstString = '1';
myFirstString.twoDigits();
myFirstString.threeDigits();
let mySecondString = '11';
mySecondString.twoDigits();
mySecondString.threeDigits();
let myThirdString = '123';
myThirdString.twoDigits();
myThirdString.threeDigits();
let myFourthString = 'my string';
myFourthString.captalize();
myFourthString.captalizeAll();
let myString = 'my string';
myFourthString.splitToArray(3);
myFourthString.splitToArray(2);
myString = '';
myString.splitToArray(2);
myString = 'Hello World!';
myString.encodeBase64();
myString = 'SGVsbG8gV29ybGQh';
myString.decodeBase64();
myString = 'Hello World!';
myString.decapitalize();
myString.reverse();
myString = '{ "name": "John Doe" }'
myString.toJson();
myString = "hello world"
myString.toJson();
myString.log();
myString.log("String");
Number
require('dot_functions_utils');
let myNumber = 1500;
myNumber.log();
myNumber.log("Number");
let myFirstNumber = 1;
myFirstNumber.twoDigits();
myFirstNumber.threeDigits();
let mySecondNumber = 11;
mySecondNumber.twoDigits();
mySecondNumber.threeDigits();
let myThirdNumber = 123;
myThirdNumber.twoDigits();
myThirdNumber.threeDigits();
let myNumber = 1234;
myNumber.twoDigits();
myNumber.threeDigits();
let financialNumber = 1000;
financialNumber.format();
financialNumber = 10;
financialNumber.format();
financialNumber = 10.50;
financialNumber.format();
financialNumber = 1000.99;
financialNumber.format();
Functions
const { threeDigits, twoDigits, generateUniqueID, log, waitFor } = require('dot_functions_utils');
let firstString = '1';
twoDigits(firstString);
threeDigits(firstString);
let secondString = '11';
twoDigits(secondString);
threeDigits(secondString);
let thirdString = '123';
twoDigits(thirdString);
threeDigits(thirdString);
generateUniqueID ();
log("My string|object", "Debug");
log({"name":"Jhon"}, "Debug");
let timeNow = (new Date).getTime();
let seconds = 10;
(async ()=>{
await waitFor(seconds);
})()