diff --git a/index.bs b/index.bs
index ac3e82e05..e6f567133 100644
--- a/index.bs
+++ b/index.bs
@@ -1885,13 +1885,7 @@ ReadableByteStreamController(stream, underlyingByteSource,
1. If IsReadableByteStreamController(*this*) is *false*, throw a *TypeError* exception.
- 1. If *this*.[[byobRequest]] is *undefined* and *this*.[[pendingPullIntos]] is not empty,
- 1. Let _firstDescriptor_ be the first element of *this*.[[pendingPullIntos]].
- 1. Let _view_ be ! Construct(%Uint8Array%, « _firstDescriptor_.[[buffer]],
- _firstDescriptor_.[[byteOffset]] + _firstDescriptor_.[[bytesFilled]], _firstDescriptor_.[[byteLength]] −
- _firstDescriptor_.[[bytesFilled]] »).
- 1. Set *this*.[[byobRequest]] to ! Construct(`ReadableStreamBYOBRequest`, « *this*, _view_ »).
- 1. Return *this*.[[byobRequest]].
+ 1. Return ! ReadableByteStreamControllerGetBYOBRequest(*this*).
get desiredSize
@@ -2285,6 +2279,20 @@ nothrow>ReadableByteStreamControllerFillPullIntoDescriptorFromQueue ( contr
1. Return _ready_.
+ReadableByteStreamControllerGetBYOBRequest ( controller )
+
+
+ 1. If _controller_.[[byobRequest]] is *undefined* and _controller_.[[pendingPullIntos]] is not empty,
+ 1. Let _firstDescriptor_ be the first element of _controller_.[[pendingPullIntos]].
+ 1. Let _view_ be ! Construct(%Uint8Array%, « _firstDescriptor_.[[buffer]],
+ _firstDescriptor_.[[byteOffset]] + _firstDescriptor_.[[bytesFilled]], _firstDescriptor_.[[byteLength]] −
+ _firstDescriptor_.[[bytesFilled]] »).
+ 1. Set _controller_.[[byobRequest]] to ! Construct(`ReadableStreamBYOBRequest`,
+ « _controller_, _view_ »).
+ 1. Return _controller_.[[byobRequest]].
+
+
ReadableByteStreamControllerGetDesiredSize ( controller )
diff --git a/reference-implementation/lib/readable-stream.js b/reference-implementation/lib/readable-stream.js
index 4852188fe..038d86d27 100644
--- a/reference-implementation/lib/readable-stream.js
+++ b/reference-implementation/lib/readable-stream.js
@@ -1212,16 +1212,7 @@ class ReadableByteStreamController {
throw byteStreamControllerBrandCheckException('byobRequest');
}
- if (this._byobRequest === undefined && this._pendingPullIntos.length > 0) {
- const firstDescriptor = this._pendingPullIntos[0];
- const view = new Uint8Array(firstDescriptor.buffer,
- firstDescriptor.byteOffset + firstDescriptor.bytesFilled,
- firstDescriptor.byteLength - firstDescriptor.bytesFilled);
-
- this._byobRequest = new ReadableStreamBYOBRequest(this, view);
- }
-
- return this._byobRequest;
+ return ReadableByteStreamControllerGetBYOBRequest(this);
}
get desiredSize() {
@@ -1772,6 +1763,19 @@ function ReadableByteStreamControllerError(controller, e) {
ReadableStreamError(stream, e);
}
+function ReadableByteStreamControllerGetBYOBRequest(controller) {
+ if (controller._byobRequest === undefined && controller._pendingPullIntos.length > 0) {
+ const firstDescriptor = controller._pendingPullIntos[0];
+ const view = new Uint8Array(firstDescriptor.buffer,
+ firstDescriptor.byteOffset + firstDescriptor.bytesFilled,
+ firstDescriptor.byteLength - firstDescriptor.bytesFilled);
+
+ controller._byobRequest = new ReadableStreamBYOBRequest(controller, view);
+ }
+
+ return controller._byobRequest;
+}
+
function ReadableByteStreamControllerGetDesiredSize(controller) {
return controller._strategyHWM - controller._totalQueuedBytes;
}