In the following:
function *bar() {
console.log( yield 1 );
console.log( yield 2 );
console.log( "done" );
}
var it = bar();
it.next();
it2 = fromTheTop(it);
function fromTheTop(it){
// ???
}
How could you write the fromTheTop
function to create a new iterator for the same source as it
came?
Notice, I'm not trying to clone the argument, so other questions such as this one are not quite right. I'm new to generators in JS, so maybe it's just a matter of phrasing the question ? TIA !
I don't think that information (where it came from) is available from an iterator. At least, I'm not seeing anything to suggest it is.