"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ExponentialBackoff = void 0; class ExponentialBackoff { constructor(opts = {}) { this.factor = 2; this.jitter = 0; this.attempts = 0; this.ms = opts.min || 100; this.max = opts.max || 10000; } duration() { var ms = this.ms * Math.pow(this.factor, this.attempts++); if (this.jitter) { var rand = Math.random(); var deviation = Math.floor(rand * this.jitter * ms); ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation; } return Math.min(ms, this.max) | 0; } reset() { this.attempts = 0; } } exports.ExponentialBackoff = ExponentialBackoff; //# sourceMappingURL=backoff.js.map