Well, if the user caches the result (in order to pass it to another
iterator) they'll get unexpected results.
Iterator A yields:
```js
{value: 1, done: false}
{value: 2, done: false}
{value: 3, done: false}
{value: 4, done: false}
```
There are two consumers for the iterator (sending the result to remote
servers that perform a calculation) which do something like:
```js
function consume(){
var toSend = iterator.next();
if(toSend.done) return Promise.resolve();
return fetch("/mydata?id="+toSend).then(function(result){
return {value: toSend.value, response: result};
});
}
```
Returning a mutable object will cause a race condition which will cause
incorrect results sometimes. Whether or not people will actually do this is
an interesting question but IMO returning mutable objects is a big lose
here.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss