X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Futils%2FUtils.js;h=e85090d49626156d4e2fdb913781762448bdcc8a;hb=a6e68f340a9c5837c767b316dee5d5121188dc47;hp=85b2d4748d91c52daab0dfbcff866f63fdedbbac;hpb=2e3ac96de33fd8c94e746fee6a7dcde877d6ddc5;p=e-mobility-charging-stations-simulator.git diff --git a/src/utils/Utils.js b/src/utils/Utils.js index 85b2d474..e85090d4 100644 --- a/src/utils/Utils.js +++ b/src/utils/Utils.js @@ -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);