-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhelpers.js
More file actions
47 lines (38 loc) · 1.94 KB
/
helpers.js
File metadata and controls
47 lines (38 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* -------------------------------------------------------------------------- */
/* Random Number Generator */
/* -------------------------------------------------------------------------- */
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
/* -------------------------------------------------------------------------- */
/* unique id generator */
/* -------------------------------------------------------------------------- */
const uuid = require('uuid');
function generateUUID() {
return uuid.v4();
}
/* -------------------------------------------------------------------------- */
/* Remove Duplicates from Array */
/* -------------------------------------------------------------------------- */
function removeDuplicates(array) {
return Array.from(new Set(array));
}
/* -------------------------------------------------------------------------- */
/* Get Current TimeStamp */
/* -------------------------------------------------------------------------- */
function getCurrentTimestamp() {
return new Date().getTime();
}
/* -------------------------------------------------------------------------- */
/* check valid Email address */
/* -------------------------------------------------------------------------- */
function isValidEmail(email) {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return emailRegex.test(email);
}
/* -------------------------------------------------------------------------- */
/* Get Random Boolean (true or false): */
/* -------------------------------------------------------------------------- */
function getRandomBoolean() {
return Math.random() < 0.5;
}