Skip to content

Instantly share code, notes, and snippets.

@aackerman
Created June 18, 2015 00:52
Show Gist options
  • Select an option

  • Save aackerman/570d56149f9e41ffffe5 to your computer and use it in GitHub Desktop.

Select an option

Save aackerman/570d56149f9e41ffffe5 to your computer and use it in GitHub Desktop.
Exponential backoff
const MAX_TIME = 30000;
export default (iteration, maxTime = MAX_TIME) => {
let time = Math.pow(2, iteration - 1) * 1000;
if (time > maxTime) { time = maxTime; }
return time;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment