Re: [streams] Extract the minimal algorithm from which we can easily infer the public behavior of the interfaces (#312)

It seems this can be achieved with a little work. E.g., in `ReadableStreamReader.prototype.read()` only the step 6 is specific to the queue-backed type ReadableStream implementation. If we extract this step as an abstract operation say `GenerateChunk()` that returns a tuple of `{ sync, value, done }`, then this algorithm would be:

- ...
- Let _result_ be GenerateChunk(**this**[[ownerReadableStream]]).
- If _result_@[[sync]] is **true**,
    - If _result_@[[done]] is **true**, call-with-rethrow CloseReadableStream(**this**@[[ownerReadableStream]]).
    - Return a new promise resolved with CreateIterResultObject(_result_@[[chunk]], **false**).
- Otherwise, ...

Now, the algorithm is describing all the constraints on how `reader.read()` should behave and interaction with other parts of the interface without saying anything about internal buffering.

POSIX `select`+`read` based ReadableStream may implement `GenerateChunk()` to generate an ArrayBufferView and read(2) and return it synchronously.

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

Received on Monday, 6 April 2015 08:22:46 UTC