Last active
August 31, 2015 18:03
-
-
Save shgysk8zer0/6ccbed999d0d52d0e5d3 to your computer and use it in GitHub Desktop.
Array.loop using Generators
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
| Array.prototype.loop = function* (times = Infinity) { | |
| while (times-- > 0) { | |
| for (let el of this) { | |
| yield el; | |
| } | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment