While loop with promises
Here’s a reusable function that I think is pretty clear. var Q = require(“q”); // `condition` is a function that returns a boolean // `body` is a function that returns a promise // returns a promise for the completion of the loop function promiseWhile(condition, body) { var done = Q.defer(); function loop() { // When … Read more