Skip to content

Instantly share code, notes, and snippets.

@LincolnBurrows
Created May 10, 2016 07:40
Show Gist options
  • Save LincolnBurrows/42989ad0e507b03ac54bcfc91a99b674 to your computer and use it in GitHub Desktop.
Save LincolnBurrows/42989ad0e507b03ac54bcfc91a99b674 to your computer and use it in GitHub Desktop.
thunkify&co code snippet
var thunkify = require('thunkify');
var co = require('co');
function myThunk(userName,callback){
callback(null , 'hello'+' '+ userName);
}
var myR = thunkify(myThunk);
function* fn(){
var a = yield myR('a');
console.log(a);
return 'over'
}
var f = fn();
var out = f.next();
console.log(out)
out.value(function (err,str){console.log(str)})
var out2 = f.next()
console.log(out2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment