mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
14 lines
361 B
TypeScript
14 lines
361 B
TypeScript
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
// This module is browser compatible.
|
|
|
|
export function _exponentialBackoffWithJitter(
|
|
cap: number,
|
|
base: number,
|
|
attempt: number,
|
|
multiplier: number,
|
|
jitter: number,
|
|
) {
|
|
const exp = Math.min(cap, base * multiplier ** attempt);
|
|
return (1 - jitter * Math.random()) * exp;
|
|
}
|