box-node-sdk
Version:
Official SDK for Box Plaform APIs
17 lines • 830 B
JavaScript
;
/**
* @fileoverview Calculate exponential backoff time
*/
// ------------------------------------------------------------------------------
// Private
// ------------------------------------------------------------------------------
// Retry intervals are between 50% and 150% of the exponentially increasing base amount
const RETRY_RANDOMIZATION_FACTOR = 0.5;
module.exports = function getRetryTimeout(numRetries, baseInterval) {
var minRandomization = 1 - RETRY_RANDOMIZATION_FACTOR;
var maxRandomization = 1 + RETRY_RANDOMIZATION_FACTOR;
var randomization = Math.random() * (maxRandomization - minRandomization) + minRandomization;
var exponential = Math.pow(2, numRetries - 1);
return Math.ceil(exponential * baseInterval * randomization);
};
//# sourceMappingURL=exponential-backoff.js.map