@persian-caesar/hycom-api
Version:
A package for easy using hycom.ir api service.
31 lines • 976 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.sleep = sleep;
exports.repeatAction = repeatAction;
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function repeatAction(action, maxAttempts = 3, delayMs = 1500) {
let attempts = 0;
while (attempts < maxAttempts) {
try {
return await action();
}
catch (e) {
attempts++;
if (attempts === maxAttempts)
return;
else
await sleep(delayMs);
}
}
}
/**
* @copyright
* Code by Sobhan-SRZA (mr.sinre) | https://github.com/Sobhan-SRZA
* Developed for Persian Caesar | https://github.com/Persian-Caesar | https://dsc.gg/persian-caesar
*
* If you encounter any issues or need assistance with this code,
* please make sure to credit "Persian Caesar" in your documentation or communications.
*/
//# sourceMappingURL=functions.js.map