Created
March 4, 2016 08:03
-
-
Save martianboy/13d520788598fbd667aa to your computer and use it in GitHub Desktop.
Retryable Promise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function retryable(fn, n) { | |
return fn().then( | |
undefined, | |
function(err) { | |
if (n > 0) | |
return retryable(fn, n - 1); | |
throw err; | |
} | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment