Skip to content

Commit 6b31c45

Browse files
jyasskinannevk
authored andcommitted
Clarify creation of ReadableStream objects
Follow-ups: * w3c/ServiceWorker#1338 * WICG/background-fetch#104
1 parent b3492ec commit 6b31c45

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

Diff for: fetch.bs

+28-17
Original file line numberDiff line numberDiff line change
@@ -1872,22 +1872,33 @@ we define common operations for {{ReadableStream}} objects. [[!STREAMS]]
18721872

18731873
<p>To
18741874
<dfn export for=ReadableStream id=concept-construct-readablestream>construct a <code>ReadableStream</code> object</dfn>
1875-
with given <var>strategy</var>, <var>pull</var> action and <var>cancel</var> action, all of which
1876-
are optional, run these steps:
1875+
optionally with a <var>highWaterMark</var>, <var>sizeAlgorithm</var> algorithm, <var>pull</var>
1876+
action, and <var>cancel</var> action, run these steps:
1877+
1878+
<p class=note>This algorithm used to take a <var ignore>strategy</var> parameter, whose
1879+
<code>highWaterMark</code> and <code>sizeAlgorithm</code> members were extracted to provide what are
1880+
now separate parameters. If another specification still passes that <var ignore>strategy</var>
1881+
parameter, please update it.
18771882

18781883
<ol>
1879-
<li><p>Let <var>init</var> be a new object.
1884+
<li><p>Let <var>startAlgorithm</var> be an algorithm that returns undefined.
1885+
1886+
<li><p>If <var>pull</var> is absent, then set it to an action that returns undefined.
1887+
1888+
<li><p>Let <var>pullAlgorithm</var> be an algorithm that returns the result of [=promise-calling=]
1889+
<var>pull</var>().
18801890

1881-
<li><p>Set <var>init</var>["pull"] to a function that runs <var>pull</var> if <var>pull</var> is
1882-
given.
1891+
<li><p>If <var>cancel</var> is absent, then set it to an action that returns undefined.
18831892

1884-
<li><p>Set <var>init</var>["cancel"] to a function that runs <var>cancel</var> if
1885-
<var>cancel</var> is given.
1893+
<li><p>Let <var>cancelAlgorithm</var> be an algorithm that takes a <var>reason</var> and returns
1894+
the result of [=promise-calling=] <var>cancel</var>(<var>reason</var>).
18861895

1887-
<li><p>Let <var>stream</var> be the result of calling the initial value of {{ReadableStream}} as
1888-
constructor with <var>init</var> and <var>strategy</var> if given.
1896+
<li><p>If <var>highWaterMark</var> is absent, then set it to 1.
18891897

1890-
<li><p>Return <var>stream</var>.
1898+
<li><p>If <var>sizeAlgorithm</var> is absent, then set it to an algorithm that returns 1.
1899+
1900+
<li><p>Return [$CreateReadableStream$](<var>startAlgorithm</var>, <var>pullAlgorithm</var>,
1901+
<var>cancelAlgorithm</var>, <var>highWaterMark</var>, <var>sizeAlgorithm</var>).
18911902
</ol>
18921903

18931904
<p>To
@@ -4123,11 +4134,10 @@ Range Requests</cite>. [[HTTP-RANGE]] However, this is not widely supported by b
41234134
<li><p>Return a <a>network error</a>.
41244135
</ol>
41254136

4126-
<li>
4127-
<p>Let <var>strategy</var> be an object. The user agent may choose any object.
4137+
<li><p>Let <var>highWaterMark</var> be a non-negative, non-NaN number, chosen by the user agent.
41284138

4129-
<p class="note no-backref"><var>strategy</var> is used to control the queuing strategy of
4130-
<var>stream</var> constructed below.
4139+
<li><p>Let <var>sizeAlgorithm</var> be an algorithm that accepts a <a>chunk</a> object and returns
4140+
a non-negative, non-NaN, non-infinite number, chosen by the user agent.
41314141

41324142
<li><p>Let <var>pull</var> be an action that <a lt=resumed for=fetch>resumes</a> the ongoing fetch
41334143
if it is <a lt=suspend for=fetch>suspended</a>.
@@ -4137,9 +4147,10 @@ Range Requests</cite>. [[HTTP-RANGE]] However, this is not widely supported by b
41374147

41384148
<li>
41394149
<p>Let <var>stream</var> be the result of
4140-
<a lt="construct a ReadableStream object" for=ReadableStream>constructing</a> a
4141-
{{ReadableStream}} object with <var>strategy</var>,
4142-
<var>pull</var> and <var>cancel</var>.
4150+
<a lt="construct a ReadableStream object" for=ReadableStream>constructing</a> a {{ReadableStream}}
4151+
object with <var>highWaterMark</var>, <var>sizeAlgorithm</var>, <var>pull</var>, and
4152+
<var>cancel</var>.
4153+
41434154
<p class="note no-backref">This construction operation will not throw an exception.
41444155

41454156
<li>

0 commit comments

Comments
 (0)