UNPKG

keep-trying

Version:

A function for creating retryable promises with configurable limit and backoff.

14 lines (13 loc) 436 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.strategies = { exact: (value) => value, linear: (base, attempt = 1) => base * attempt, exponential: (base, attempt = 1, maxTime = 3000) => Math.min(maxTime, base * Math.pow(2, attempt)) }; exports.choose = (strategy) => { if (typeof strategy === 'function') { return strategy; } return exports.strategies[strategy]; };