Andrea Giammarchi (2015-02-16T18:18:45.000Z)
d at domenic.me (2015-02-21T00:39:44.971Z)
In fact, you can specify a generator function with an infinite loop (like the infamous while (true) { .. }) that essentially never finishes. While that's usually madness or a mistake in a normal JS program, with generator functions it's perfectly sane and sometimes exactly what you want to do! just probably the most read piece about JS generators .... http://davidwalsh.name/es6-generators Hence the potential problem caused by `while (!yielded.next().done)` thousands of objects ... I agree that's not the best way to go with generators, but I've seen many code-bases based on similar automagic resolution. Other example in going async and the `runGenerator` function: http://davidwalsh.name/async-generators ```js // run (async) a generator to completion// Note: simplified approach: no error handling herefunction runGenerator(g) { var it = g(), ret; // asynchronously iterate over generator (function iterate(val){ ret = it.next( val ); if (!ret.done) { // poor man's "is it a promise?" test if ("then" in ret.value) { // wait on the promise ret.value.then( iterate ); } // immediate value: just send right back in else { // avoid synchronous recursion setTimeout( function(){ iterate( ret.value ); }, 0 ); } } })();} ``` And since one of the purpose/side-effect of generators is to make code look synchronous, I don't think Kyle went too far or anything, he simply showed some pattern that I've seen already applied here and there. So yes, behind libraries or on users hands, the amount of garbage can be "too damn high"