UNPKG

@amaui/utils

Version:
13 lines (12 loc) 453 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const asyncMethodRetry = (method, retries = 4, timeout = 40) => (new Promise((resolve, reject) => { method() .then(resolve) .catch(error => { if (retries <= 1) return reject(error); setTimeout(() => asyncMethodRetry(method, retries - 1, timeout).then(resolve, reject), timeout); }); })); exports.default = asyncMethodRetry;