Skip to content

Instantly share code, notes, and snippets.

@ccnokes
Last active January 17, 2018 03:57
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 ccnokes/cc89a55d61b5ee1cce3194a0e8c5ba49 to your computer and use it in GitHub Desktop.
Save ccnokes/cc89a55d61b5ee1cce3194a0e8c5ba49 to your computer and use it in GitHub Desktop.
basis of a functional way to traverse iterators
function iterate(iterator, cb) {
let next = iterator.next();
while(!next.done) {
cb(next.value);
next = iterator.next();
}
}
// iterate(new Set([1,2,3]).values(), console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment