Guest User

Untitled

a guest
Nov 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. const MIN_TIMEOUT = 1000;
  2. const FACTOR = 1.5;
  3. const ATTEMPTS = 22;
  4.  
  5. const range = (n) => Array.apply(null, {length: n}).map(Number.call, Number);
  6. const timeout = (attempt) => Math.min(MIN_TIMEOUT * Math.pow(FACTOR, attempt), Infinity);
  7. const toSeconds = (ms) => Math.floor((ms / 1000));
  8.  
  9. const retries = range(ATTEMPTS).map(attempt => toSeconds(timeout(attempt)));
  10. console.log(retries);
Add Comment
Please, Sign In to add comment