Skip to content

Instantly share code, notes, and snippets.

@wtfaremyinitials
Created April 2, 2015 20:53
Show Gist options
  • Save wtfaremyinitials/b13771a80b963eae77fb to your computer and use it in GitHub Desktop.
Save wtfaremyinitials/b13771a80b963eae77fb to your computer and use it in GitHub Desktop.
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