Re: [whatwg/streams] `ReadableStreamDefaultReader.read()` return values (#1117)

> though I believe that returning done = true when there are no more chunks (keeping the stream open) may be a more intuitive design choice

When there are currently no chunks available for reading but the stream is not closed, the promise returned by `reader.read()` will remain pending until either a chunk becomes available or the stream becomes closed. This matches the semantics of the (async) [iterator protocol](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterator_protocol), so it works well together with other JavaScript APIs.

I understand that it may be desirable to inspect whether there are any chunks already available in a stream's queue. Unfortunately, there's currently no API for that...

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1117#issuecomment-806125423

Received on Wednesday, 24 March 2021 19:47:42 UTC