Claude Pache (2014-08-19T06:48:30.000Z)
domenic at domenicdenicola.com (2014-08-26T18:22:15.333Z)
This can be worked around. Basically, ask the generator to advance to the first `yield` at instantiation, and retrieve the value of the "first" `next()` with that `yield`. For example: ```js // the echo generator, dropping the first .next() function* echo() { var x while (true) { x = yield x } } var iter = echo() iter.next(3) // {value: undefined, done: false} iter.next(8) // {value: 8, done: false} iter.next(1) // {value: 1, done: false} // the same, advancing to the first `yield` at instantiation class echo2 extends echo { construct(...args) { let iter = super(...args) iter.next() return iter } } var iter = echo2() iter.next(3) // {value: 3, done: false} iter.next(8) // {value: 8, done: false} iter.next(1) // {value: 1, done: false} ```
domenic at domenicdenicola.com (2014-08-26T18:22:08.339Z)
This can be worked around. Basically, ask the generator to advance to the first `yield` at instantiation, and retrieve the value of the "first" `next()` with that `yield`. For example: ```js // the echo generator, dropping the first .next() function* echo() { var x while (true) { x = yield x } } var iter = echo() iter.next(3) // {value: undefined, done: false} iter.next(8) // {value: 8, done: false} iter.next(1) // {value: 1, done: false} // the same, advancing to the first `yield` at instantiation class echo2 extends echo { construct(...args) { let iter = super(...args) iter.next() return iter } } var iter = echo2() iter.next(3) // {value: 3, done: false} iter.next(8) // {value: 8, done: false} iter.next(1) // {value: 1, done: false} ``` —Claude