Message from JavaScript discussions

March 2018

— Well, it's basically lazy lists that interop with for..of

— 

Anyway part of this functionality may be accessible without generator-refregirator at all. we can lock scope once and be ok.

— What you mean by "lazy list"?

— Infinite lists for instance

— Fibonacci, natural numbers, etc

— Infinite?? how is that

— Oke, infinite loop in code.. you mean "lazy list", oke

— 

function* numbers() {
let i = 0;
while (true)
yield ++i;
}

— A generator makes caching like this effortless

— Since it stores the state of the function on every yield

— It's like a horse in a vacuum imo

— 

for(const n of numbers()) {
if (n >= 10)
break;
console.log(n);
}
// logs numbers 1-9