UNPKG

@segment/analytics-core

Version:

This package represents core 'shared' functionality that is shared by analytics packages. This is not designed to be used directly, but internal to analytics-node and analytics-browser.

10 lines 530 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.backoff = void 0; function backoff(params) { var random = Math.random() + 1; var _a = params.minTimeout, minTimeout = _a === void 0 ? 500 : _a, _b = params.factor, factor = _b === void 0 ? 2 : _b, attempt = params.attempt, _c = params.maxTimeout, maxTimeout = _c === void 0 ? Infinity : _c; return Math.min(random * minTimeout * Math.pow(factor, attempt), maxTimeout); } exports.backoff = backoff; //# sourceMappingURL=backoff.js.map