Created
February 22, 2016 11:51
-
-
Save petruisfan/75af4cf9eb21dd01e82e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var co = require('co'); | |
var functionThatReturnsAPromise = function() { | |
var promise = new Promise(function(resolve, reject) { | |
setTimeout(function() { | |
resolve("Some value"); | |
}, 1000); | |
}); | |
return promise; | |
}; | |
co(function* () { | |
var result = yield functionThatReturnsAPromise(); | |
console.log(result); | |
}).catch(function(err) { | |
console.log(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment