@coxy/reply-count-loop
v1.0.2
Published
Repeats function calls until there is a result
Downloads
5
Readme
Register function
const random = () => {
if (Math.random() > 0.01) {
throw new Error(':(');
}
return 'Success!';
}
Add to loop
import replayCountLoop from '@coxy/reply-count-loop';
const loop = replayCountLoop(random, {
onError: e => console.log('error', e.message),
attempts: 20,
delay: 100,
})
loop.then(console.log);
loop.catch(console.error);