Re: [streams] What types does ReadableByteStream's reader's read(x) accept and return? (#295)

Wait! I was re-reading [my thread on es-discuss](https://esdiscuss.org/topic/idiomatic-representation-of-buffer-bytesread) about this question and I realized @jorendorff had a great solution that I forgot to list in the OP: just make the return type be the same type of view as gets passed in to the read(view) method!

I guess in that solution we disallow `.read(arrayBuffer)` directly. (We could still allow `.read({ buffer: arrayBuffer })` which is equivalent to `.read({ buffer: arrayBuffer, byteOffset: 0, byteLength: arrayBuffer.byteLength, constructor: Uint8Array })`, if we wanted.) What do you think?

> Are you fine with the idea that byteLength === 0 is EOF?

We should be able to avoid making this assumption (even though it will always be true, I think) by using the `done` part of the `{ value, done }` tuple.

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

Received on Thursday, 12 March 2015 08:03:42 UTC