@signumjs/util
Version:
Useful utilities and tools for building Signum Network applications
22 lines • 640 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.asyncRetry = asyncRetry;
async function asyncRetry(args) {
const { asyncFn, onFailureAsync, retryCount = 1, maxRetrials = 20 } = args;
try {
return await asyncFn();
}
catch (e) {
if (retryCount > maxRetrials) {
throw e;
}
const shouldRetry = await onFailureAsync(e, retryCount);
if (shouldRetry) {
await asyncRetry({ asyncFn, onFailureAsync, retryCount: retryCount + 1 });
}
else {
throw e;
}
}
}
//# sourceMappingURL=asyncRetry.js.map