utility-pro

1.0.3 • Public • Published

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 array
  • sortNumber() : To sort array of number
  • removeDup() : To remove duplicate elements from array
  • removeDupAndSort() : To remove duplicate elements from array of number and sort it
  • isEven() : To check if every element of array is even number or not
  • isPrime() : To check if given number is prime or not
  • isNull() : To check if given variable is null or not
  • isUndefined() : To check if given variable is undefined or not
  • createRandomEmail() It will create a random email for you
  • createRandomWord() It will create a random word of desire number of alphabet for you
  • createRandomPhoneNumber() It will create a random phone number for you
  • createRandomURL() It will create a random url of desire length for you
  • createRandomIP() 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());// utilitypro1518028437757@npm.com
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.. :)

Package Sidebar

Install

npm i utility-pro

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

6.57 kB

Total Files

4

Last publish

Collaborators

  • saurabh_kumar