UNPKG

websocket-ts

Version:

<div> <div align="center"> <img src="https://raw.githubusercontent.com/jjxxs/websocket-ts/gh-pages/websocket-ts-logo.svg" alt="websocket-ts" width="300" height="65" /> </div> <p align="center"> <img src="https://github.com/jjxxs/websocket-ts

30 lines 701 B
/** * ConstantBackoff always returns the same backoff-time. */ export class ConstantBackoff { /** * Creates a new ConstantBackoff. * @param backoff the backoff-time to return */ constructor(backoff) { this._retries = 0; if (!Number.isInteger(backoff) || backoff < 0) { throw new Error("Backoff must be a positive integer"); } this.backoff = backoff; } get retries() { return this._retries; } get current() { return this.backoff; } next() { this._retries++; return this.backoff; } reset() { this._retries = 0; } } //# sourceMappingURL=constantbackoff.js.map