Promise retry snippet
Promise.retry = function(executor, times) { const step = () => new Promise(executor); let promise = step(); for(let i = 1; i < times; i++) { promise = promise.catch(step); } return promise; };