Created
March 9, 2017 03:56
-
-
Save togakangaroo/ad047db7e86f1810ec42d4569ec62cbb to your computer and use it in GitHub Desktop.
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
window.console = skewer | |
var createCounter = (startVal = 0) => { | |
let state = startVal | |
return { | |
next: () => { | |
if(state < (10 + startVal)) | |
return {value: state+=1} | |
return {done: true} | |
} | |
} | |
} | |
var counter = createCounter(5) | |
var {done, value} = counter.next() | |
while(!done) { | |
console.log(value) | |
const x = counter.next() | |
done = x.done | |
value = x.value | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment