[streams] rsReader.readBatch(numberOfChunks)? rbsReader.read(view, { waitUntilDone: true })? (#320)

Some ideas came up in conversation with @wanderview in IRC today and I thought would be worth logging.

The first is a potential `readBatch(numberOfChunks)` method that would allow you to wait for multiple chunks at once. This would presumably return a promise fulfilled with an array. Empty array, or array of less than `numberOfChunks` length, would mean you reached end of stream. The motivation here was performance though, which is weak without data. My instinct is to push this off into the future.

The second was the question of how `read(view)` works for BYOB readable byte stream readers. I had been envisioning it as doing a direct pass through to the underlying byte source. So for example for files, you'll usually get back `view.byteLength` bytes (unless at the end of the file), whereas for sockets, you'll get back some unknown number of bytes <= `view.byteLength`. However, we could instead say that the underlying source needs to either fill the entire `view` or close the stream. (I am not sure we could enforce this programmatically, but it could be something we advise underlying source implementations to do, and in particular fetch body stream.) We could even add an option that lets you toggle between the behaviors.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/320

Received on Tuesday, 7 April 2015 23:14:30 UTC