Calls a function repeatedly while a condition returns true and then resolves the promise
$ npm install --save promise-whilst
const promiseWhilst = require('promise-whilst');
let count = 0;
promiseWhilst(() => {
return count < 5;
}, () => {
count++;
}).then(() => {
console.log(count);
//=> 5
});
Executes action
repeatedly while 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
Should return a boolean of whether to continue.
Type: function
Action to run for each iteration.
You can return a promise and it will be handled.
MIT © Sindre Sorhus