Skip to content

Instantly share code, notes, and snippets.

@tlkahn
Created December 23, 2015 21:32
Show Gist options
  • Save tlkahn/1059a8279bb528d3ad92 to your computer and use it in GitHub Desktop.
Save tlkahn/1059a8279bb528d3ad92 to your computer and use it in GitHub Desktop.
recursive es6 generator
var gen = function *(count){
console.log("gen called: ", count);
if (count < 20)
yield count;
else
yield *gen(count/2);
}
var g = gen(100);
do {
var n = g.next();
console.log("val: ", n.value);
} while (!n.done)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment