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
43 lines • 1.29 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConstantBackoff = void 0;
/**
* ConstantBackoff always returns the same backoff-time.
*/
var ConstantBackoff = /** @class */ (function () {
/**
* Creates a new ConstantBackoff.
* @param backoff the backoff-time to return
*/
function ConstantBackoff(backoff) {
this._retries = 0;
if (!Number.isInteger(backoff) || backoff < 0) {
throw new Error("Backoff must be a positive integer");
}
this.backoff = backoff;
}
Object.defineProperty(ConstantBackoff.prototype, "retries", {
get: function () {
return this._retries;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ConstantBackoff.prototype, "current", {
get: function () {
return this.backoff;
},
enumerable: false,
configurable: true
});
ConstantBackoff.prototype.next = function () {
this._retries++;
return this.backoff;
};
ConstantBackoff.prototype.reset = function () {
this._retries = 0;
};
return ConstantBackoff;
}());
exports.ConstantBackoff = ConstantBackoff;
//# sourceMappingURL=constantbackoff.js.map
;