Re: [streams] Change the model for ReadableStream to have async read() (#288)

Discussed with @tyoshino offline.

We think introducing ByteSource and removing ExclusiveStreamReader is the right direction.

```
class ByteSource {
  // Return an associated readable byte stream.
  stream(option)

  // Read |size| bytes from this source and write it into |sink|.
  // Return a promise that will be fulfilled when the operation is completed.
  pipeBytes(sink, size)
}
```

While a stream returned by `stream()` is not closed or `pipeBytes()` is running, `stream()` and `pipeBytes()` will fail.
Consequences:

- There is no ExclusiveStreamReader. ReadableStream.pipeTo can be defined, but it is completely user-level.
- Instead, ByteSource.pipeBytes offers the off-thread data transfer.

This greatly simplifies the situation. Regarding fetch, Body.body is a ByteSource.


---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/288#issuecomment-76178348

Received on Thursday, 26 February 2015 13:35:09 UTC