UNPKG

478 BJavaScriptView Raw
1'use strict';
2
3const getProfile = require('./profile').getProfile;
4const retry = require('promise-retry');
5
6async function getRetryOptions() {
7 const profile = await getProfile();
8 const retryOptions = {
9 retries: profile.retries,
10 factor: 2,
11 minTimeout: 1 * 1000,
12 randomize: true
13 };
14
15 return retryOptions;
16}
17
18async function promiseRetry(fn) {
19 const retryOptions = await getRetryOptions();
20 return retry(fn, retryOptions);
21}
22
23module.exports = promiseRetry;
\No newline at end of file