chore (minor): use ** in lieu of Math.pow

This commit is contained in:
naskya 2024-04-21 06:40:53 +09:00
parent 488323cc8e
commit 2760e7feee
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C

View file

@ -34,7 +34,7 @@ export function initialize<T>(name: string, limitPerSec = -1) {
function apBackoff(attemptsMade: number, err: Error) {
const baseDelay = 60 * 1000; // 1min
const maxBackoff = 8 * 60 * 60 * 1000; // 8hours
let backoff = (Math.pow(2, attemptsMade) - 1) * baseDelay;
let backoff = (2 ** attemptsMade - 1) * baseDelay;
backoff = Math.min(backoff, maxBackoff);
backoff += Math.round(backoff * Math.random() * 0.2);
return backoff;