utility-pro
v1.0.3
Published
NPM package for some utility functions to make your coding easy :)
Downloads
7
Maintainers
Readme
utility-pro
NPM package which provides some utility functions to make your coding easy :)
command to Install :
npm install utility-pro --save
list of functions contain in this package :
sum()
: To calculate sum of all the numbers in arraysortNumber()
: To sort array of numberremoveDup()
: To remove duplicate elements from arrayremoveDupAndSort()
: To remove duplicate elements from array of number and sort itisEven()
: To check if every element of array is even number or notisPrime()
: To check if given number is prime or notisNull()
: To check if given variable is null or notisUndefined()
: To check if given variable is undefined or notcreateRandomEmail()
It will create a random email for youcreateRandomWord()
It will create a random word of desire number of alphabet for youcreateRandomPhoneNumber()
It will create a random phone number for youcreateRandomURL()
It will create a random url of desire length for youcreateRandomIP()
It will create a random IPv4 for you
Example:
const utilPro = require('utility-pro');
const a;
const arr = [3,2,4,4,2,1,7,5,9,4];
console.log(utilPro.sum(arr)); // 41
console.log(utilPro.sortNumber(arr)); // [ 1, 2, 2, 3, 4, 4, 4, 5, 7, 9 ]
console.log(utilPro.removeDup(arr)); // [ 3, 2, 4, 1, 7, 5, 9 ]
console.log(utilPro.removeDupAndSort(arr)); // [ 1, 2, 3, 4, 5, 7, 9 ]
console.log(utilPro.isEven([2,3,4,5])); //false
console.log(utilPro.isEven([2,6,4,8])); //true
console.log(utilPro.isPrime(5)); // true
console.log(utilPro.isPrime(4)); // false
console.log(utilPro.isNull(a)); // false
console.log(utilPro.isUndefined(a));// true
console.log(utilPro.createRandomEmail());// [email protected]
console.log(utilPro.createRandomWord(5));// efedb
console.log(utilPro.createRandomPhoneNumber());// 8995359431
console.log(utilPro.createRandomURL(5));// www.sdasd.com
console.log(utilPro.createRandomIP());// 192.168.1.50
more functions will be added in future.. stay tuned.. :)