Created
August 16, 2016 18:53
-
-
Save robbestad/0829f12fa479d7464d67d292c616d8f2 to your computer and use it in GitHub Desktop.
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* generator(...seq) { | |
| while (true) { | |
| for (let item of seq) { | |
| yield item; | |
| } | |
| } | |
| } | |
| const gen = generator('1','2','3'); | |
| for (let i = 0; i < 10; i++) { | |
| console.log(gen.next().value); | |
| } | |
| // -> 1 2 3 1 2 3 etc.. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment