AFAICT, `return()` throwing an exception (versus performing a `return`) is
necessary if you want to forward it like in the following code:
```js
function* take(n, iterable) {
let iterator = iterable[Symbol.iterator]();
try {
while (n > 0) {
let item = iterator.next();
if (item.done) {
return item.value;
}
yield item.value;
n--;
}
} catch (e) {
if (e instanceof ReturnException) {
iterator.return(e.returnValue); // forward
}
ยทยทยท
}
}
```
Seems important w.r.t. composability of generators.
Axel
--
Dr. Axel Rauschmayer
[email protected]
rauschma.de
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss