How can I get the nth value of a generator?
function *index() { let x = 0; while(true) yield x++; } // the 1st value let a = index(); console.log(a.
A simple loop will do:
let n = 10, iter = index(); while (--n > 0) iter.next(); console.log(iter.next().value); // 9