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
| /* | |
| Say I need to iterate over [1, 2, 3], yielding a value | |
| at a time but once I reach the final value, I want to | |
| keep receiving the values over and over again, making | |
| it a repeated sequence: 1, 2, 3, 1, 2, 3, 1 and so on... | |
| */ | |
| const cyclic = list => (function* () { | |
| while (true) for (let item of list) yield item | |
| }()) |
NewerOlder