Skip to content

Instantly share code, notes, and snippets.

Avatar

Tuktarov Renat yandzee

View GitHub Profile
@yandzee
yandzee / index.js
Last active Sep 3, 2020
Code retry with promises
View index.js
// Author: Renat Tuktarov (renat@sourcerer.io)
const retry = function(fn, prev) {
return new Promise((current, reject) => {
const resolve = _ => (prev && prev()) || current();
fn(resolve, delay => {
setTimeout(_ => {
retry(fn, resolve);
}, delay);