Skip to content

Instantly share code, notes, and snippets.

@bendc
Created December 9, 2015 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bendc/ba511625d867873b9472 to your computer and use it in GitHub Desktop.
Save bendc/ba511625d867873b9472 to your computer and use it in GitHub Desktop.
Iterate over an Iterator object using recursion
const set = new Set(["foo", "bar"]);
const iterate = iterator => {
const iteration = iterator.next();
if (iteration.done) return;
console.log(iteration.value);
return iterate(iterator);
};
iterate(set.values()); // => foo, bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment