Skip to content

Instantly share code, notes, and snippets.

@akhoury
Last active August 19, 2016 20:21
Show Gist options
  • Save akhoury/a7023f149fcb173ae3616b61b677a938 to your computer and use it in GitHub Desktop.
Save akhoury/a7023f149fcb173ae3616b61b677a938 to your computer and use it in GitHub Desktop.
promiseWhile()
function promiseWhile (condition, execute) {
return new Promise(function(resolve, reject) {
var iterate = function () {
if (condition()) {
return execute()
.then(iterate)
.catch(reject);
}
return resolve();
};
return iterate();
});
}
module.exports = promiseWhile;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment