Skip to content

Commit dc1fbd2

Browse files
committed
Rename option to maxRetries
1 parent fee7a30 commit dc1fbd2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib/util.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ const ApiError = require('./error');
1313
*
1414
* @param {Function} request - A function that returns a Promise that resolves with a Response object
1515
* @param {object} options
16-
* @param {number} [options.retries] - Number of retries. Defaults to 5
16+
* @param {number} [options.maxRetries] - Maximum number of retries. Defaults to 5
1717
* @param {number} [options.interval] - Interval between retries in milliseconds. Defaults to 500
1818
* @returns {Promise<Response>} - Resolves with the response object
1919
* @throws {ApiError} If the request failed
2020
*/
2121
async function withAutomaticRetries(request, options = {}) {
22-
const retries = options.retries || 5;
22+
const maxRetries = options.maxRetries || 5;
2323
const interval = options.interval || 500;
2424
const jitter = options.jitter || 100;
2525

@@ -60,14 +60,14 @@ async function withAutomaticRetries(request, options = {}) {
6060
}
6161
}
6262

63-
if (Number.isInteger(retries) && retries > 0) {
63+
if (Number.isInteger(maxRetries) && maxRetries > 0) {
6464
if (Number.isInteger(delay) && delay > 0) {
65-
await sleep(interval * 2 ** (options.retries - retries));
65+
await sleep(interval * 2 ** (options.maxRetries - maxRetries));
6666
}
6767
attempts += 1;
6868
}
6969
/* eslint-enable no-await-in-loop */
70-
} while (attempts < retries);
70+
} while (attempts < maxRetries);
7171

7272
return request();
7373
}

0 commit comments

Comments
 (0)