Re: [streams] Support reading bytes into buffers allocated by user code on platforms where only async read is available (#253)

> I guess it still works if we ...

Right

> { value, done }

Agreed. I thought you prefer not returning something structured, so suggested the empty view holding the detached buffer.

{ value, done } can have three modes:
- `{ undefined, true }`
- `{ someValue, true }`
- `{ someValue, false }`

`{ undefined, true }` corresponds to EOS. `{ someValue, false }` corresponds to non-EOS.

To realize the view returning, `{ someValue, true }` is necessary which was not in the EOS based world. The question is whether the common `read(undefined)` user should be prepared to see `{ someValue, true }` or not. This is useful for doing both returning a value and signaling close at once. But the user cannot determine if it's `{ someValue, true }` or `{ undefined, true }` if **undefined** is a valid return value for the stream. Since closure may be signaled separate from the last value reading, we cannot kill `{ undefined, true }`.


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

Received on Thursday, 5 March 2015 21:49:03 UTC