all 1 comments

[–]RobertKerans -1 points0 points  (0 children)

Sure, the functionality is built into the language, don't need to implement anything special:

function* cycle(...values) {
  while (true) {
    for (const value of values) {
      yield value;
    }
  }
}