Created
February 18, 2014 22:49
-
-
Save pvdz/9082105 to your computer and use it in GitHub Desktop.
POC, simple transformation :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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