Skip to content

Instantly share code, notes, and snippets.

@pvdz
Created February 18, 2014 22:49
Show Gist options
  • Select an option

  • Save pvdz/9082105 to your computer and use it in GitHub Desktop.

Select an option

Save pvdz/9082105 to your computer and use it in GitHub Desktop.
POC, simple transformation :)
function * foo() {
a();
yield x;
b();
}
// =>
function * foo() {
var started = false;
var finished = false;
function f1() {
a();
}
function f2() {
x;
b();
}
return {
next: function () {
if (!started) {
started = true;
f1();
} else if (!finished) {
finished = true;
f2();
} else {
throw 'nope';
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment