Browse Source

feat(ts) migrate retry to TS

dev0
Naman Jain 6 months ago
parent
commit
42bafae816
No account linked to committer's email address
2 changed files with 14 additions and 14 deletions
  1. 0
    14
      modules/util/Retry.js
  2. 14
    0
      modules/util/Retry.ts

+ 0
- 14
modules/util/Retry.js View File

@@ -1,14 +0,0 @@
1
-/**
2
-* Gets next timeout using the full jitter pattern.
3
-*
4
-* NOTE that there are no checks for argument correctness, so either do the math or use defaults.
5
-*
6
-* @param {number} retry - The retry number.
7
-* @param {number} minDelay - The minimal delay in milliseconds.
8
-* @param {number} base - The exponent base.
9
-* @returns {number} - The amount of waiting before trying another time given in milliseconds.
10
-* @private
11
-*/
12
-export function getJitterDelay(retry, minDelay = 500, base = 2) {
13
-    return Math.floor((Math.random() * ((Math.pow(base, retry) * 1000) - minDelay)) + minDelay);
14
-}

+ 14
- 0
modules/util/Retry.ts View File

@@ -0,0 +1,14 @@
1
+/**
2
+ * Gets next timeout using the full jitter pattern.
3
+ *
4
+ * NOTE that there are no checks for argument correctness, so either do the math or use defaults.
5
+ *
6
+ * @param {number} retry - The retry number.
7
+ * @param {number} minDelay - The minimal delay in milliseconds.
8
+ * @param {number} base - The exponent base.
9
+ * @returns {number} - The amount of waiting before trying another time given in milliseconds.
10
+ * @private
11
+ */
12
+export function getJitterDelay(retry: number, minDelay: number = 500, base: number = 2): number {
13
+    return Math.floor((Math.random() * ((Math.pow(base, retry) * 1000) - minDelay)) + minDelay);
14
+}

Loading…
Cancel
Save