UNPKG

@udus/notion-renderer

Version:
9 lines (8 loc) 378 B
export const exponentialBackoffFactory = (initialDelay = 1, factor = 2, maxDelay = Infinity) => { let currentDelay = initialDelay; return async () => { console.info(`Waiting ${currentDelay} seconds...`); await new Promise((resolve) => setTimeout(resolve, currentDelay * 1000)); currentDelay = Math.min(currentDelay * factor, maxDelay); }; };