aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/exponential-backoff/dist/options.d.ts
diff options
context:
space:
mode:
authorpack <pack@packgekko.xyz>2026-08-09 10:37:07 +0000
committerpack <pack@packgekko.xyz>2026-08-09 10:37:07 +0000
commit55a4f1fc869e41aca748c63d3018f0448b1606e0 (patch)
treed132d1d01772b6d53faee3e63c534dea5706b78a /node_modules/exponential-backoff/dist/options.d.ts
downloadcrud-55a4f1fc869e41aca748c63d3018f0448b1606e0.tar.gz
first commit
Diffstat (limited to '')
-rw-r--r--node_modules/exponential-backoff/dist/options.d.ts55
1 files changed, 55 insertions, 0 deletions
diff --git a/node_modules/exponential-backoff/dist/options.d.ts b/node_modules/exponential-backoff/dist/options.d.ts
new file mode 100644
index 0000000..94e0bb4
--- /dev/null
+++ b/node_modules/exponential-backoff/dist/options.d.ts
@@ -0,0 +1,55 @@
+/**
+ * Type of jitter to apply to the delay.
+ * - `"none"`: no jitter is applied
+ * - `"full"`: full jitter is applied (random value between `0` and `delay`)
+ */
+export declare type JitterType = "none" | "full";
+export declare type BackoffOptions = Partial<IBackOffOptions>;
+export interface IBackOffOptions {
+ /**
+ * Decides whether the `startingDelay` should be applied before the first call.
+ * If `false`, the first call will occur without a delay.
+ * @defaultValue `false`
+ */
+ delayFirstAttempt: boolean;
+ /**
+ * Decides whether a [jitter](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/)
+ * should be applied to the delay. Possible values are `"full"` and `"none"`.
+ * @defaultValue `"none"`
+ */
+ jitter: JitterType;
+ /**
+ * The maximum delay, in milliseconds, between two consecutive attempts.
+ * @defaultValue `Infinity`
+ */
+ maxDelay: number;
+ /**
+ * The maximum number of times to attempt the function.
+ * Must be at least `1`.
+ * @defaultValue `10`
+ */
+ numOfAttempts: number;
+ /**
+ * The `retry` function can be used to run logic after every failed attempt (e.g. logging a message,
+ * assessing the last error, etc.).
+ * It is called with the last error and the upcoming attempt number.
+ * Returning `true` will retry the function as long as the `numOfAttempts` has not been exceeded.
+ * Returning `false` will end the execution.
+ * @defaultValue a function that always returns `true`.
+ * @param e The last error thrown by the function.
+ * @param attemptNumber The upcoming attempt number.
+ * @returns `true` to retry the function, `false` to end the execution
+ */
+ retry: (e: any, attemptNumber: number) => boolean | Promise<boolean>;
+ /**
+ * The delay, in milliseconds, before executing the function for the first time.
+ * @defaultValue `100`
+ */
+ startingDelay: number;
+ /**
+ * The `startingDelay` is multiplied by the `timeMultiple` to increase the delay between reattempts.
+ * @defaultValue `2`
+ */
+ timeMultiple: number;
+}
+export declare function getSanitizedOptions(options: BackoffOptions): IBackOffOptions;