Add runtime persitence on OCPP parameters.
[e-mobility-charging-stations-simulator.git] / src / utils / Utils.js
index 16901b00e4f6f272d01295391f9ed499b128a841..e85090d49626156d4e2fdb913781762448bdcc8a 100644 (file)
@@ -1,8 +1,8 @@
-const uuidV4 = require('uuid/v4');
+const {v4: uuid} = require('uuid');
 
 class Utils {
   static generateGUID() {
-    return uuidV4();
+    return uuid();
   }
 
   static sleep(ms) {
@@ -100,6 +100,22 @@ class Utils {
     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);