anticipate

retries asynchronous functions until they succeed

Usage no npm install needed!

<script type="module">
  import anticipate from 'https://cdn.skypack.dev/anticipate';
</script>

README

anticipate

Retries asynchronous functions until they succeed.

Install

npm install anticipate

Example (PogoScript)

anticipate = require 'anticipate'

anticipate.trying @(callback) every 0.1 seconds
    something flaky with (callback)
.succeeds within 10 tries @(result)
    it worked (result)
.otherwise @(error)
    oh noes (error)

Example (JavaScript)

anticipate = require('anticipate');

anticipate.tryingEverySeconds(function(callback) {
    somethingFlakyWith(callback);
}, 0.1).succeedsWithinTries(10, function(result) {
    itWorked(result);
}).otherwise(function(error) {
    ohNoes(error);
});

License

BSD