@aws-amplify/core
Version:
Core category of aws-amplify
20 lines (17 loc) • 566 B
JavaScript
import { MAX_DELAY_MS } from './constants.mjs';
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
/**
* @private
* Internal use of Amplify only
*/
function jitteredBackoff(maxDelayMs = MAX_DELAY_MS) {
const BASE_TIME_MS = 100;
const JITTER_FACTOR = 100;
return attempt => {
const delay = 2 ** attempt * BASE_TIME_MS + JITTER_FACTOR * Math.random();
return delay > maxDelayMs ? false : delay;
};
}
export { jitteredBackoff };
//# sourceMappingURL=jitteredBackoff.mjs.map