- From: Reilly Grant <notifications@github.com>
- Date: Mon, 19 Jul 2021 13:05:24 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 19 July 2021 20:05:37 UTC
@domenic, can you reopen this issue? If there's action to take here then it should be done at the Streams API level. While it might be nice syntactically to have `cancel()` return any bytes left in the queue I think this can be polyfilled with, ```js const finalReadPromise = reader.read(); await reader.cancel(); const finalRead = await finalReadPromise; ``` If there was any data left in the queue then it will be in `finalRead.value`. Otherwise, if the read was blocked waiting for more data then `finalReadvalue` will be `undefined`. The key insight here being that you can do a "non-blocking" read to see if there are queued bytes by not awaiting on the `Promise` it returns. Once you call `cancel()` then that `Promise` is guaranteed to have resolved one way or another. -- 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/1147#issuecomment-882823201
Received on Monday, 19 July 2021 20:05:37 UTC