Calculates jittered delay for exponential backoff
The attempt number (0-indexed)
Base delay in milliseconds
Maximum delay in milliseconds
Whether to add jitter
The calculated delay in milliseconds
const delay = calculateBackoffDelay(3, 1000, 30000, true); // delay could be around 8000 ms with jitter Copy
const delay = calculateBackoffDelay(3, 1000, 30000, true); // delay could be around 8000 ms with jitter
Calculates jittered delay for exponential backoff