@@ -6809,36 +6809,33 @@ a chunk</dfn> from a {{ReadableStreamDefaultReader}} |reader|, given a [=read re
6809
6809
6810
6810
<div algorithm="read all bytes">
6811
6811
<p> To <dfn export for="ReadableStreamDefaultReader" lt="read all bytes|reading all bytes">read all
6812
- bytes</dfn> from a {{ReadableStreamDefaultReader}} |reader|, perform the following steps. The
6813
- result will be a {{Promise}} for a [=byte sequence=] .
6814
-
6815
- 1. Let |promise| be [=a new promise=] .
6816
- 1. Let |bytes| be an empty [=byte sequence=] .
6817
- 1. [=Read-loop=] given |reader|, |bytes|, and |promise|.
6818
- 1. Return |promise|.
6812
+ bytes</dfn> from a {{ReadableStreamDefaultReader}} |reader|, given |successSteps|,
6813
+ which is an algorithm accepting a [=byte sequence=] , and |failureSteps|, which is an algorithm
6814
+ accepting a JavaScript value: [=read-loop=] given |reader|, a new [=byte sequence=] ,
6815
+ |successSteps|, and |failureSteps|.
6819
6816
6820
6817
<div algorithm="read-loop">
6821
- For the purposes of the above algorithm, to <dfn>read-loop</dfn> given |reader|, |bytes|, and
6822
- |promise |:
6818
+ For the purposes of the above algorithm, to <dfn>read-loop</dfn> given |reader|, |bytes|,
6819
+ |successSteps|, and |failureSteps |:
6823
6820
6824
6821
1. Let |readRequest| be a new [=read request=] with the following [=struct/items=] :
6825
6822
: [=read request/chunk steps=] , given |chunk|
6826
6823
::
6827
- 1. If |chunk| is not a {{Uint8Array}} object, [=reject=] |promise | with a {{TypeError}} and
6824
+ 1. If |chunk| is not a {{Uint8Array}} object, call |failureSteps | with a {{TypeError}} and
6828
6825
abort these steps.
6829
6826
1. Append the bytes represented by |chunk| to |bytes|.
6830
- 1. [=Read-loop=] given |reader|, |bytes|, and |promise |.
6827
+ 1. [=Read-loop=] given |reader|, |bytes|, |successSteps|, and |failureSteps |.
6831
6828
<p class="note"> This recursion could potentially cause a stack overflow if implemented
6832
6829
directly. Implementations will need to mitigate this, e.g. by using a non-recursive variant
6833
6830
of this algorithm, or [=queue a microtask|queuing a microtask=] , or using a more direct
6834
6831
method of byte-reading as noted below.
6835
6832
6836
6833
: [=read request/close steps=]
6837
6834
::
6838
- 1. [=Resolve=] |promise | with |bytes|.
6835
+ 1. Call |successSteps | with |bytes|.
6839
6836
: [=read request/error steps=] , given |e|
6840
6837
::
6841
- 1. [=Reject=] |promise | with |e|.
6838
+ 1. Call |failureSteps | with |e|.
6842
6839
1. Perform ! [$ReadableStreamDefaultReaderRead$] (|reader|, |readRequest|).
6843
6840
</div>
6844
6841
0 commit comments