domenic at domenicdenicola.com (2014-08-26T18:22:46.630Z)
Le 19 août 2014 à 15:21, Kevin Smith <zenparsing at gmail.com> a écrit : > Nice pattern! Would this also work? Sadly, it doesn't work; for the delegated iterator always receives `undefined` for its first iteration. :-( See [1], last algorithm of the section, step 5. [1]: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-generator-function-definitions-runtime-semantics-evaluation
Le 19 août 2014 à 15:21, Kevin Smith <zenparsing at gmail.com> a écrit : > > // the same, advancing to the first `yield` at instantiation > class echo2 extends echo { > construct(...args) { > let iter = super(...args) > iter.next() > return iter > } > } > > Nice pattern! Would this also work? > > var skipFirst = genFn => function*(...args) { > var iter = genFn(...args); > iter.next(); > yield * iter; > }; > > var echo2 = skipFirst(echo); > Sadly, it doesn't work; for the delegated iterator always receives `undefined` for its first iteration. :-( See [1], last algorithm of the section, step 5. [1] http://people.mozilla.org/~jorendorff/es6-draft.html#sec-generator-function-definitions-runtime-semantics-evaluation —Claude -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140819/eefb844d/attachment.html>