DefinitelyTyped/types/backo2/index.d.ts

60 lines
1.3 KiB
TypeScript

// Type definitions for backo2 1.0
// Project: https://github.com/mokesmokes/backo
// Definitions by: Retsam <https://github.com/Retsam>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
type BackoffOptions = Partial<{
min: number,
max: number,
jitter: number,
factor: number,
}>;
declare class Backoff {
constructor(opts?: BackoffOptions);
/**
* The number of previous attempts
*/
attempts: number;
/**
* A lower bound on the duration between attempts
*/
ms: number;
/**
* An upper bound on the duration between attempts
*/
max: number;
/**
* An upper bound on the variance around the duration between attempts
*/
jitter: number;
/**
* The base to which the attempt is raised as an exponent
*/
factor: number;
/**
* Compute the backoff duration and increment the number of attempts
*/
duration(): number;
/**
* Reset the number of attempts
*/
reset(): void;
/**
* Set the minimum duration between attempts
*/
setMin(min: number): void;
/**
* Set the maximum duration between attempts
*/
setMax(max: number): void;
/**
* Set the jitter
*/
setJitter(jitter: number): void;
}
export = Backoff;