Skip to content

Instantly share code, notes, and snippets.

@petruisfan
Created February 22, 2016 11:51
Show Gist options
  • Save petruisfan/75af4cf9eb21dd01e82e to your computer and use it in GitHub Desktop.
Save petruisfan/75af4cf9eb21dd01e82e to your computer and use it in GitHub Desktop.
#!/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