Given the provided (very simple) generator, is it possible to return the generator back to its original state to use again?
var generator = function*() {
Whenever you need to "reset" an iterable, just toss the old one away and make a new one.
var generator = function*() {
yield 1;
yield 2;
yield 3;
};
const makeIterable = () => generator()
for (let x of makeIterable()) {
console.log(x);
}
// At this point, iterable is consumed.
// Is there a method for moving iterable back
// to the start point by only without re-calling generator(),
// (or possibly by re-calling generator(), only by using prototype
// or constructor methods available within the iterable object)
// so the following code would work again?
for (let x of makeIterable()) {
console.log(x);
}