domenic at domenicdenicola.com (2014-08-26T18:22:29.846Z)
> ```js
> // 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);
If we have decorators, then we can write:
@skipFirst
function echo() { /*_*/ }
which is fairly pleasant.
Still, it seems like we're papering over a hole. In principle, why
shouldn't we be able to access the first next argument?
> > > // 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); If we have decorators, then we can write: @skipFirst function echo() { /*_*/ } which is fairly pleasant. Still, it seems like we're papering over a hole. In principle, why shouldn't we be able to access the first next argument? -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140819/d7a8285e/attachment.html>