Skip to content

Commit

Permalink
Editorial: use "pull from bytes" algorithm
Browse files Browse the repository at this point in the history
Introduced in whatwg/streams#1263.

Fixes #1610.
  • Loading branch information
saschanaz committed Apr 28, 2023
1 parent ca10f49 commit 4502481
Showing 1 changed file with 2 additions and 23 deletions.
25 changes: 2 additions & 23 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -6122,7 +6122,7 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:
</ol>

<li>
<p>Let |buffer| be an empty buffer that can have bytes appended to it.
<p>Let |buffer| be an empty [=byte sequence=].

<p class="note">This represents an internal buffer inside the network layer of the user agent.

Expand All @@ -6146,28 +6146,7 @@ optional boolean <var>forceNewConnection</var> (default false), run these steps:
[=task destination=].

<ol>
<li><p>Let |available| be the size of |buffer|.

<li><p>Let |desiredSize| be |available|.

<li><p>If |stream|'s [=ReadableStream/current BYOB request view=] is non-null, then set
|desiredSize| to |stream|'s [=ReadableStream/current BYOB request view=]'s
[=BufferSource/byte length=].

<li><p>Let |extractSize| be the smaller value of |available| and |desiredSize|.

<li><p>Let <var>bytes</var> be the result of extracting |extractSize| of bytes from
<var>buffer</var>.

<li><p>If |stream|s [=ReadableStream/current BYOB request view=] is non-null, then
[=ArrayBufferView/write=] |bytes| into |stream|'s
[=ReadableStream/current BYOB request view=], and set |view| to |stream|'s
[=ReadableStream/current BYOB request view=].

<li>Otherwise, set |view| to the result of [=ArrayBufferView/create|creating=] a
{{Uint8Array}} from |bytes| in |stream|'s [=relevant Realm=].

<li><p>[=ReadableStream/Enqueue=] |view| into |stream|.
<li><p>[=ReadableStream/Pull from bytes=] |buffer| into |stream|.

<li><p>If |stream| is [=ReadableStream/errored=], then [=fetch controller/terminate=]
|fetchParams|'s [=fetch params/controller=].
Expand Down

0 comments on commit 4502481

Please sign in to comment.