Add Power.Active.Import measurand support.
[e-mobility-charging-stations-simulator.git] / src / utils / Utils.js
index db2017a8f6cee711e71750952646dfdab84d1171..9d071a415faabcb5a086ce1a6ab765d8320736bc 100644 (file)
@@ -1,6 +1,6 @@
-const {v4: uuid} = require('uuid');
+import {v4 as uuid} from 'uuid';
 
-class Utils {
+export default class Utils {
   static generateUUID() {
     return uuid();
   }
@@ -100,17 +100,14 @@ class Utils {
   }
 
   static getRandomFloat(max, min = 0) {
-    if (min) {
-      return Math.random() * (max - min + 1) + min;
-    }
-    return Math.random() * max + 1;
+    return Math.random() < 0.5 ? (1 - Math.random()) * (max - min) + min : Math.random() * (max - min) + min;
   }
 
   static getRandomInt(max, min = 0) {
     if (min) {
-      return Math.floor(Utils.getRandomFloat(max, min));
+      return Math.floor(Math.random() * (max - min + 1) + min);
     }
-    return Math.floor(Utils.getRandomFloat(max));
+    return Math.floor(Math.random() * max + 1);
   }
 
   static roundTo(number, scale) {
@@ -184,5 +181,3 @@ class Utils {
     return !Object.keys(obj).length;
   }
 }
-
-module.exports = Utils;