1 | export interface BackoffOptions {
|
2 | initialDelay?: number;
|
3 | multiplier?: number;
|
4 | jitter?: number;
|
5 | maxDelay?: number;
|
6 | }
|
7 | export declare class BackoffTimeout {
|
8 | private callback;
|
9 | |
10 |
|
11 |
|
12 | private readonly initialDelay;
|
13 | |
14 |
|
15 |
|
16 | private readonly multiplier;
|
17 | |
18 |
|
19 |
|
20 | private readonly maxDelay;
|
21 | |
22 |
|
23 |
|
24 |
|
25 | private readonly jitter;
|
26 | |
27 |
|
28 |
|
29 | private nextDelay;
|
30 | |
31 |
|
32 |
|
33 |
|
34 |
|
35 | private timerId;
|
36 | |
37 |
|
38 |
|
39 | private running;
|
40 | |
41 |
|
42 |
|
43 |
|
44 | private hasRef;
|
45 | |
46 |
|
47 |
|
48 |
|
49 | private startTime;
|
50 | constructor(callback: () => void, options?: BackoffOptions);
|
51 | private runTimer;
|
52 | /**
|
53 | * Call the callback after the current amount of delay time
|
54 | */
|
55 | runOnce(): void;
|
56 | /**
|
57 | * Stop the timer. The callback will not be called until `runOnce` is called
|
58 | * again.
|
59 | */
|
60 | stop(): void;
|
61 | /**
|
62 | * Reset the delay time to its initial value. If the timer is still running,
|
63 | * retroactively apply that reset to the current timer.
|
64 | */
|
65 | reset(): void;
|
66 | /**
|
67 | * Check whether the timer is currently running.
|
68 | */
|
69 | isRunning(): boolean;
|
70 | /**
|
71 | * Set that while the timer is running, it should keep the Node process
|
72 | * running.
|
73 | */
|
74 | ref(): void;
|
75 | /**
|
76 | * Set that while the timer is running, it should not keep the Node process
|
77 | * running.
|
78 | */
|
79 | unref(): void;
|
80 | }
|