- From: Domenic Denicola <notifications@github.com>
- Date: Thu, 30 Mar 2023 22:38:13 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/pull/1263/review/1366276447@github.com>
@domenic commented on this pull request.
So one issue here is that this "buffer" type, and the operations on it, are undefined. The operations seem to be:
- "extracting from" which returns a byte sequence while presumably modifying the buffer;
- "size" which returns an integer; and
- "append" in fetch
I was OK with this as a one-off over in fetch, but since we're encountering this a couple times, we should think a bit harder about whether it's the route we want to go down. I.e., how should we represent underlying platform byte buffers in specs.
Options I can see:
- Leave it as-is in this PR. It's fine, probably people know what it means.
- Define a "platform byte buffer" type, probably in Streams, with a couple sentences describing what it generally corresponds to and explaining the two operations you can apply to one of these platform byte buffers.
- Use byte sequences instead. Then specs like Fetch would say something like "Let |buffer| be an empty [=byte sequence=]. NOTE: this represents the internal buffer inside the network layer of the user agent".
I think using byte sequences would be most reasonable. WDYT?
> @@ -6752,6 +6752,29 @@ mark=] is greater than zero.
[$ReadableByteStreamControllerEnqueue$](|stream|.[=ReadableStream/[[controller]]=], |chunk|).
</div>
+<div algorithm>
+ To <dfn export for="ReadableStream">pull from buffer</dfn> |buffer| into a {{ReadableStream}}
+ |stream|:
+
+ 1. Let |available| be the size of |buffer|.
+ 1. Let |desiredSize| be |available|.
+ 1. If |stream|'s [=ReadableStream/current BYOB request view=] is non-null, then set
+ |desiredSize| to |stream|'s [=ReadableStream/current BYOB request view=]'s
+ [=BufferSource/byte length=].
+ 1. Let |extractSize| be the smaller value of |available| and |desiredSize|.
+ 1. Let |bytes| be the result of extracting |extractSize| of bytes from |buffer|.
+ 1. If |stream|s [=ReadableStream/current BYOB request view=] is non-null, then:
```suggestion
1. If |stream|'s [=ReadableStream/current BYOB request view=] is non-null, then:
```
--
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1263#pullrequestreview-1366276447
You are receiving this because you are subscribed to this thread.
Message ID: <whatwg/streams/pull/1263/review/1366276447@github.com>
Received on Friday, 31 March 2023 05:38:25 UTC