UNPKG

box-node-sdk

Version:

Official SDK for Box Plaform APIs

17 lines 828 B
"use strict"; /** * @fileoverview Calculate exponential backoff time */ // ------------------------------------------------------------------------------ // Private // ------------------------------------------------------------------------------ // Retry intervals are between 50% and 150% of the exponentially increasing base amount var 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