From e381f25014db461a8f3c81eacb1bf84588bf75de Mon Sep 17 00:00:00 2001
From: Mattias Buelens <mattias@buelens.com>
Date: Sat, 16 Sep 2023 12:57:48 +0200
Subject: [PATCH] Move readIntoRequest to last argument

---
 index.bs                                             | 12 ++++++------
 .../lib/ReadableStreamBYOBReader-impl.js             |  2 +-
 .../lib/abstract-ops/readable-streams.js             |  8 ++++----
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/index.bs b/index.bs
index 52729a3f9..67ca070b1 100644
--- a/index.bs
+++ b/index.bs
@@ -1476,7 +1476,7 @@ value: newViewOnSameMemory, done: true }</code> for closed streams. If the strea
   : [=read-into request/error steps=], given |e|
   ::
    1. [=Reject=] |promise| with |e|.
- 1. Perform ! [$ReadableStreamBYOBReaderRead$]([=this=], |view|, |readIntoRequest|, |options|["{{ReadableStreamBYOBReaderReadOptions/min}}"]).
+ 1. Perform ! [$ReadableStreamBYOBReaderRead$]([=this=], |view|, |options|["{{ReadableStreamBYOBReaderReadOptions/min}}"], |readIntoRequest|).
  1. Return |promise|.
 </div>
 
@@ -2581,7 +2581,7 @@ create them does not matter.
    : [=read-into request/error steps=]
    ::
     1. Set |reading| to false.
-  1. Perform ! [$ReadableStreamBYOBReaderRead$](|reader|, |view|, |readIntoRequest|, 1).
+  1. Perform ! [$ReadableStreamBYOBReaderRead$](|reader|, |view|, 1, |readIntoRequest|).
  1. Let |pull1Algorithm| be the following steps:
   1. If |reading| is true,
    1. Set |readAgainForBranch1| to true.
@@ -2881,8 +2881,8 @@ The following abstract operations support the implementation and manipulation of
 
 <div algorithm>
  <dfn abstract-op lt="ReadableStreamBYOBReaderRead"
- id="readable-stream-byob-reader-read">ReadableStreamBYOBReaderRead(|reader|, |view|,
- |readIntoRequest|, |min|)</dfn> performs the following steps:
+ id="readable-stream-byob-reader-read">ReadableStreamBYOBReaderRead(|reader|, |view|, |min|,
+ |readIntoRequest|)</dfn> performs the following steps:
 
  1. Let |stream| be |reader|.[=ReadableStreamGenericReader/[[stream]]=].
  1. Assert: |stream| is not undefined.
@@ -2890,7 +2890,7 @@ The following abstract operations support the implementation and manipulation of
  1. If |stream|.[=ReadableStream/[[state]]=] is "`errored`", perform |readIntoRequest|'s [=read-into
     request/error steps=] given |stream|.[=ReadableStream/[[storedError]]=].
  1. Otherwise, perform ! [$ReadableByteStreamControllerPullInto$](|stream|.[=ReadableStream/[[controller]]=],
-    |view|, |readIntoRequest|, |min|).
+    |view|, |min|, |readIntoRequest|).
 </div>
 
 <div algorithm>
@@ -3570,7 +3570,7 @@ The following abstract operations support the implementation of the
 <div algorithm>
  <dfn abstract-op lt="ReadableByteStreamControllerPullInto"
  id="readable-byte-stream-controller-pull-into">ReadableByteStreamControllerPullInto(|controller|,
- |view|, |readIntoRequest|, |min|)</dfn> performs the following steps:
+ |view|, |min|, |readIntoRequest|)</dfn> performs the following steps:
 
  1. Let |stream| be |controller|.[=ReadableByteStreamController/[[stream]]=].
  1. Let |elementSize| be 1.
diff --git a/reference-implementation/lib/ReadableStreamBYOBReader-impl.js b/reference-implementation/lib/ReadableStreamBYOBReader-impl.js
index 05546419a..30023c817 100644
--- a/reference-implementation/lib/ReadableStreamBYOBReader-impl.js
+++ b/reference-implementation/lib/ReadableStreamBYOBReader-impl.js
@@ -51,7 +51,7 @@ class ReadableStreamBYOBReaderImpl {
       closeSteps: chunk => resolvePromise(promise, { value: chunk, done: true }),
       errorSteps: e => rejectPromise(promise, e)
     };
-    aos.ReadableStreamBYOBReaderRead(this, view, readIntoRequest, options.min);
+    aos.ReadableStreamBYOBReaderRead(this, view, options.min, readIntoRequest);
     return promise;
   }
 
diff --git a/reference-implementation/lib/abstract-ops/readable-streams.js b/reference-implementation/lib/abstract-ops/readable-streams.js
index 15d598b03..9d20ff705 100644
--- a/reference-implementation/lib/abstract-ops/readable-streams.js
+++ b/reference-implementation/lib/abstract-ops/readable-streams.js
@@ -647,7 +647,7 @@ function ReadableByteStreamTee(stream) {
         reading = false;
       }
     };
-    ReadableStreamBYOBReaderRead(reader, view, readIntoRequest, 1);
+    ReadableStreamBYOBReaderRead(reader, view, 1, readIntoRequest);
   }
 
   function pull1Algorithm() {
@@ -913,7 +913,7 @@ function ReadableStreamReaderGenericRelease(reader) {
   reader._stream = undefined;
 }
 
-function ReadableStreamBYOBReaderRead(reader, view, readIntoRequest, min) {
+function ReadableStreamBYOBReaderRead(reader, view, min, readIntoRequest) {
   const stream = reader._stream;
 
   assert(stream !== undefined);
@@ -923,7 +923,7 @@ function ReadableStreamBYOBReaderRead(reader, view, readIntoRequest, min) {
   if (stream._state === 'errored') {
     readIntoRequest.errorSteps(stream._storedError);
   } else {
-    ReadableByteStreamControllerPullInto(stream._controller, view, readIntoRequest, min);
+    ReadableByteStreamControllerPullInto(stream._controller, view, min, readIntoRequest);
   }
 }
 
@@ -1562,7 +1562,7 @@ function ReadableByteStreamControllerProcessReadRequestsUsingQueue(controller) {
   }
 }
 
-function ReadableByteStreamControllerPullInto(controller, view, readIntoRequest, min) {
+function ReadableByteStreamControllerPullInto(controller, view, min, readIntoRequest) {
   const stream = controller._stream;
 
   let elementSize = 1;