1.0.2 • Published 2 years ago

@coxy/reply-count-loop v1.0.2

Weekly downloads
17
License
MIT
Repository
github
Last release
2 years ago

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);