Re: [whatwg/streams] add @@asyncIterator to ReadableStreamDefaultReader (#950)

> Should we alias, or move? I guess alias is nice since it lets you manually consume a couple with a given reader, then switch to for-await-of?

But then what would this do?

```javascript
const reader = stream.getReader();
for await (const chunk of reader) {
  break;
}
reader.read();
```
Would the `read()` work? It would seem odd if the reader was unlocked behind the user's back.

If you want to use a reader first, and then iterate, it seems reasonable to wait for your read and then `releaseLock()`, ie.

```javascript
const reader = stream.getReader();
const { value, done } = await reader.read();
// do something with first chunk
reader.releaseLock();
for await (const chunk of stream) {
  // do something with rest of the chunks
}
```

In general, I think having multiple ways to do something tends to lead to confused arguments about which way is "right". So I favour only having the methods on ReadableStream.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/950#issuecomment-417620710

Received on Friday, 31 August 2018 10:18:05 UTC