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

@domenic commented on this pull request.



> + To <dfn export for="ReadableStream">enqueue bytes</dfn> into a {{ReadableStream}} |stream| given a
+ [=byte sequence=] |bytes|:
+
+ 1. Assert: |stream|.[=ReadableStream/[[controller]]=] [=implements=]
+    {{ReadableByteStreamController}}.
+ 1. Assert: |bytes|'s [=byte sequence/length=] is positive.
+ 1. Let |byobRequest| be !
+    [$ReadableByteStreamControllerGetBYOBRequest$](|stream|.[=ReadableStream/[[controller]]=]).
+ 1. If |byobRequest| is null, or
+    |byobRequest|.[=ReadableStreamBYOBRequest/[[view]]=].\[[ByteLength]] &lt; |bytes|'s [=byte
+    sequence/length=], then:
+  1. Let |uint8Array| be a new {{Uint8Array}} wrapping an {{ArrayBuffer}} backed by |bytes|.
+  1. Perform ! [$ReadableByteStreamControllerEnqueue$](|stream|.[=ReadableStream/[[controller]]=],
+     |uint8Array|).
+ 1. Otherwise,
+  1. Write |bytes| into

Once we start using https://github.com/heycam/webidl/pull/987 there will be such an assertion transitively, but it can't hurt to add it here too.

-- 
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_r645539842

Received on Friday, 4 June 2021 12:45:27 UTC