-const uuidV4 = require('uuid/v4');
+const {v4: uuid} = require('uuid');
class Utils {
static generateGUID() {
- return uuidV4();
+ return uuid();
}
static sleep(ms) {
return changedID;
}
+ static convertToBoolean(value) {
+ let result = false;
+ // Check boolean
+ if (value) {
+ // Check the type
+ if (typeof value === 'boolean') {
+ // Already a boolean
+ result = value;
+ } else {
+ // Convert
+ result = (value === 'true');
+ }
+ }
+ return result;
+ }
+
static getRandomInt(max, min) {
if (min) {
return Math.floor((Math.random() * (max - min)) + min);