Le 19 août 2014 à 15:21, Kevin Smith <[email protected]> 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_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss