Skip to content

Instantly share code, notes, and snippets.

View yandzee's full-sized avatar

Tuktarov Renat yandzee

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