Re: [whatwg/streams] ReadableStreamBYOBReader.prototype.readFully(view) (#1143)

> Is this going to be accompanied with a timeout parameter or abort signal?

There's a separate discussion ongoing to make reads abortable in #1103. Combined with whatwg/dom#951, you could implement timeouts on reads like this:
```javascript
const reader = readable.getReader({ mode: 'byob', signal: AbortSignal.timeout(10_000) });
const { done, value } = await reader.read(new Uint8Array(1024), { atLeast: 32 });
```
* If at least 32 bytes arrive within 10 seconds, then `value` is a `Uint8Array` containing at least 32 bytes (and up to 1024 bytes).
* If fewer than 32 bytes arrive in that time, the `read()` call rejects and the reader is released. Any received bytes remain in the readable's queue, and can be read later by acquiring a new reader.

(Note that these APIs are not yet finalized, I'm basing this example on the *current* proposals.)

-- 
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/1143#issuecomment-977183000

Received on Tuesday, 23 November 2021 21:27:15 UTC