Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generator function tasks
var MiningTask = function* MiningTask() {
for(var i=0; i<5; i++) {
yield breakBlock();
}
}
var tasks = [];
tasks.push(MiningTask());
var tick = function() {
var task = tasks.pop();
var r = task.next();
if(!r.done)
tasks.push(r);
process.nextTick(tick);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.