ts-retry
Version:
A little retry tool to execute a function until the function is successful. Can also bind a timeout to a function. This lib is usable in typescript, in javascript, in node, in SPA tools (rest, Vue, Svelte...) and browser (available in ESM and common js fo
19 lines (18 loc) • 800 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRetryParameters = void 0;
const options_1 = require("./options");
function getRetryParameters(currentTry, retryOptions) {
const fullOptions = Object.assign(Object.assign({}, (0, options_1.getDefaultRetryOptions)()), retryOptions);
return Object.assign(Object.assign({}, fullOptions), { currentTry, maxTry: fullOptions.maxTry || options_1.defaultMaxTry, delay: getDelay(fullOptions.delay), until: fullOptions.until ? fullOptions.until : () => true });
}
exports.getRetryParameters = getRetryParameters;
function getDelay(delay) {
if (delay === undefined) {
return () => options_1.defaultDelay;
}
if (typeof delay === 'function') {
return delay;
}
return () => delay;
}