Calls a function repeatedly until a condition returns true and then resolves the promise
- See Also
$ npm install --save promise-do-until
import promiseDoUntil from 'promise-do-until';
let count = 0;
promiseDoUntil(() => {
count++;
}, () => {
return count === 5;
}).then(() => {
console.log(count);
// => 5
});
// ...
let max = 0;
promiseDoUntil(() => {
max++;
}, () => {
return max > -1;
}).then(() => {
console.log(max);
// => 1
});
Executes action
repeatedly until condition
returns true
and then resolves the promise. Rejects if action
returns a promise that rejects or if an error is thrown anywhere.
Type: function
Action to run for each iteration.
You can return a promise and it will be handled.
Type: function
Should return a boolean of whether to continue.
ISC © Buster Collings