Re: [whatwg/streams] Add ReadableStreamBYOBReader.readFully() (#1145)

I've been thinking about whether we want to expose `pullIntoDescriptor.[[readFully]]` to the underlying byte source, e.g. something like `ReadableStreamBYOBRequest.isReadFullyRequest`.
* Pro: the underlying byte source might be able to optimize for large reads, instead of receiving repeated `pull()` calls with continuations of the same BYOB request. For example, for `ReadableByteStreamTee`, we could forward a `readFully()` request from the branch all the way to the original stream.
* Con: we might end up with *too much* buffering. Again using the `ReadableByteStreamTee` example: if the first branch does `readFully(new Uint8Array(1024))` and then the second branch does `read(new Uint8Array(1))`, the second branch wouldn't receive any data until the underlying source of the original stream has filled up the entire view of the forwarded `readFully()` request from the first branch. (This case probably deserves its own WPT test... 🤔)

So yeah, it might be an optimization opportunity, but it might also be a footgun. At least for now, I'll leave `ReadableStreamBYOBRequest` untouched. 🙂

-- 
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/pull/1145#issuecomment-886183342

Received on Sunday, 25 July 2021 10:57:26 UTC