Re: [whatwg/streams] Allow other specifications to create readable byte streams (#1130)

@MattiasBuelens commented on this pull request.



> +<div algorithm>
+ To <dfn export for="ReadableStream">enqueue</dfn> the JavaScript value |chunk| into a
+ {{ReadableStream}} |stream|:
+
+ 1. If |stream|.[=ReadableStream/[[controller]]=] [=implements=]
+    {{ReadableStreamDefaultController}},
+  1. Perform ! [$ReadableStreamDefaultControllerEnqueue$](|stream|.[=ReadableStream/[[controller]]=],
+     |chunk|).
+ 1. Otherwise,
+  1. Assert: |stream|.[=ReadableStream/[[controller]]=] [=implements=]
+     {{ReadableByteStreamController}}.
+  1. Assert: |chunk| is an {{ArrayBufferView}}.
+  1. Let |byobRequest| be !
+     [$ReadableByteStreamControllerGetBYOBRequest$](|stream|.[=ReadableStream/[[controller]]=]).
+  1. If |byobRequest| is non-null, and |chunk|.\[[ViewedArrayBuffer]].\[[ArrayBufferData]] is the
+     same [=Data Block=] as |byobRequest|.\[[view]].\[[ViewedArrayBuffer]].\[[ArrayBufferData]],

D'oh, how could I forget? I even [explained this in #1123](https://github.com/whatwg/streams/pull/1123#issuecomment-840861165). 😛 

We *could* make two separate algorithms: one for enqueuing a new chunk, and another for responding with a (transferred) BYOB request view. We still can't check if the given buffer is a transferred version of the BYOB request's buffer, so we'd have to rely on the calling specification to not mess this up.

Or yeah, we could just forbid transferring for now. 😁

-- 
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/1130#discussion_r669990146

Received on Wednesday, 14 July 2021 22:14:37 UTC