Let's assume that we have following generator:
var gen = function* () {
for (var i = 0; i < 10; i++ ) {
yield i;
}
};
What is the most efficient way to loop through the iterator ?
Currently I do it with checking manually if done
property is set to true
or not:
var item
, iterator = gen();
while (item = iterator.next(), !item.done) {
console.log( item.value );
}