Last active
January 17, 2018 03:57
-
-
Save ccnokes/cc89a55d61b5ee1cce3194a0e8c5ba49 to your computer and use it in GitHub Desktop.
basis of a functional way to traverse iterators
This file contains 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
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