I am trying to implement a while loop using promises.
The method outlined here seems to work. http://blog.victorquinn.com/javascript-promise-while-loop it uses a function like this
var Promise = require('bluebird');
var promiseWhile = function(condition, action) {
    var resolver = Promise.defer();
    var loop = function() {
        if (!condition()) return resolver.resolve();
        return Promise.cast(action())
            .then(loop)
            .catch(resolver.reject);
    };
    process.nextTick(loop);
    return resolver.promise;
};
This seems to use anti-patterns and deprecated methods like cast and defer.
Does anyone know a better or more modern way to accomplish this?
Thanks
 
     
     
     
    