Skip to content

Instantly share code, notes, and snippets.

@tujlaky
Created June 15, 2015 06:01
Show Gist options
  • Save tujlaky/e9cc29e7c12cc3bd0a18 to your computer and use it in GitHub Desktop.
Save tujlaky/e9cc29e7c12cc3bd0a18 to your computer and use it in GitHub Desktop.
recursive promise
var Promise = require('bluebird');
var testRecursive = function(count) {
return new Promise(function(resolve, reject) {
if ( count > 0 ) {
console.log('asd');
return testRecursive(count-1).then(function(c) {
resolve(c);
});
} else {
resolve(count);
}
});
};
testRecursive(5)
.then(function(count) {
console.log('Resolved: ' + count);
})
.catch(function(err) {
throw err;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment