Re: [whatwg/streams] Add ReadableStreamBYOBReader.read(view, { min }) (#1145)

@MattiasBuelens commented on this pull request.



>   method steps are:
 
  1. If |view|.\[[ByteLength]] is 0, return [=a promise rejected with=] a {{TypeError}} exception.
  1. If |view|.\[[ViewedArrayBuffer]].\[[ArrayBufferByteLength]] is 0, return [=a promise rejected
     with=] a {{TypeError}} exception.
  1. If ! [$IsDetachedBuffer$](|view|.\[[ViewedArrayBuffer]]) is true, return
     [=a promise rejected with=] a {{TypeError}} exception.
+ 1. Let |minimumFill| be undefined.
+ 1. If |options|["{{ReadableStreamBYOBReaderReadOptions/min}}"] was given,
+  1. If |options|["{{ReadableStreamBYOBReaderReadOptions/min}}"] is 0, return [=a promise
+     rejected with=] a {{TypeError}} exception.
+  1. If |view| has a \[[TypedArrayName]] internal slot,
+   1. If |options|["{{ReadableStreamBYOBReaderReadOptions/min}}"] > |view|.\[[ArrayLength]],
+      return [=a promise rejected with=] a {{RangeError}} exception.
+   1. Let |elementSize| be the element size specified in [=the typed array constructors table=] for
+      |view|.\[[TypedArrayName]].
+   1. Set |minimumFill| to |options|["{{ReadableStreamBYOBReaderReadOptions/min}}"] *
+      |elementSize|.
+  1. Otherwise (i.e., it is a {{DataView}}),
+   1. If |options|["{{ReadableStreamBYOBReaderReadOptions/min}}"] > |view|.\[[ByteLength]],
+      return [=a promise rejected with=] a {{RangeError}} exception.
+   1. Set |minimumFill| to |options|["{{ReadableStreamBYOBReaderReadOptions/min}}"].

Fixed it. I replaced `minimumFill` with `min` in *both* `ReadableStreamBYOBReaderRead` and `ReadableByteStreamControllerPullInto`, and now we only compute the final `minimumFill` value inside `ReadableByteStreamControllerPullInto`. Much better! 🙂

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1145#discussion_r1327946877
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/pull/1145/review/1629948311@github.com>

Received on Saturday, 16 September 2023 11:01:20 UTC