A simple utility to repeat a function until a truthy value is encountered.
npm install repeat-untilcallback as the second paremeter.``javascript
var repeatUntil = require('repeat-until');
repeatUntil(100, function (callback) {
doSomethingElse(param1, param2, function (err, ready) {
if (err) { return callback(err); }
return callback(null, ready, 123, 'xyz', ...);
});
}, function (err, num, str, ...) {
// Repeat finished...
});
`
javascript
repeatUntil(delay, taskFn, finalFn);
`* delay - The number of ms to delay each function call for. The delay is applied before the first call to
taskFn.
* taskFn - The task to perform. It is passed one parameter callback(err, stop)`.