refactor: add more sanity checks to charging profiles handling code
[e-mobility-charging-stations-simulator.git] / src / utils / Utils.ts
index 54b0751022130ba18e3a238cc58a78d741acb39e..48d0587cbce16e9db798c48877795325e8088eff 100644 (file)
@@ -262,11 +262,12 @@ export const insertAt = (str: string, subStr: string, pos: number): string =>
  * Computes the retry delay in milliseconds using an exponential backoff algorithm.
  *
  * @param retryNumber - the number of retries that have already been attempted
+ * @param maxDelayRatio - the maximum ratio of the delay that can be randomized
  * @returns delay in milliseconds
  */
 export const exponentialDelay = (retryNumber = 0, maxDelayRatio = 0.2): number => {
   const delay = Math.pow(2, retryNumber) * 100;
-  const randomSum = delay * maxDelayRatio * secureRandom(); // 0-20% of the delay
+  const randomSum = delay * maxDelayRatio * secureRandom(); // 0-(maxDelayRatio*100)% of the delay
   return delay + randomSum;
 };