- From: Adam Rice <notifications@github.com>
- Date: Thu, 10 Sep 2020 15:51:20 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/pull/1073/review/486354772@github.com>
@ricea commented on this pull request.
Apart from my concern about read-loop, this lgtm.
Sorry for the delayed review.
> + 1. Let |promise| be [=a new promise=].
+ 1. Let |bytes| be an empty [=byte sequence=].
+ 1. [=Read-loop=] given |reader|, |bytes|, and |promise|.
+ 1. Return |promise|.
+
+ <div algorithm="read-loop">
+ For the purposes of the above algorithm, to <dfn>read-loop</dfn> given |reader|, |bytes|, and
+ |promise|:
+
+ 1. Let |readRequest| be a new [=read request=] with the following [=struct/items=]:
+ : [=read request/chunk steps=], given |chunk|
+ ::
+ 1. If |chunk| is not a {{Uint8Array}} object, [=reject=] |promise| with a {{TypeError}} and
+ abort these steps.
+ 1. Append the bytes represented by |chunk| to |bytes|.
+ 1. [=Read-loop=] given |reader|, |bytes|, and |promise|.
This can call ReadableStreamDefaultReaderRead re-entrantly, which is a bit scary. As far as I can tell it's safe in the standard language, but implementations can fail due to stack overflow. Easiest fix would probably be to post a microtask.
> +
+<div algorithm>
+ <p>To <dfn export for="ReadableStream" lt="tee|teeing">tee</dfn> a {{ReadableStream}} |stream|,
+ return ? [$ReadableStreamTee$](|stream|, true).
+
+ <p class="note">Because we pass true as the second argument to [$ReadableStreamTee$], the second
+ branch returned will have its [=chunks=] cloned (using HTML's [=serializable objects=] framework)
+ from those of the first branch. This prevents consumption of one of the branches from interfering
+ with the other.
+</div>
+
+<h4 id="other-specs-rs-introspect">Introspection</h4>
+
+The following predicates can be used on arbitrary {{ReadableStream}} objects. However, note that
+this direct introspection is not possible via the public JavaScript API, and so specifications
+should instead use the algorithms in [[#other-specs-rs-reading]]. (For
Since `locked` _is_ part of the public API, this might not be the best example.
> + algorithm <dfn export for="WritableStream/create"><var>abortAlgorithm</var></dfn>, an optional
+ number <dfn export for="WritableStream/create"><var>highWaterMark</var></dfn> (default 1), an
+ optional algorithm <dfn export for="WritableStream/create"><var>sizeAlgorithm</var></dfn>, perform
+ the following steps. |writeAlgorithm| must be an algorithm that accepts a [=chunk=] object and
+ returns a promise. If given, |closeAlgorithm| and |abortAlgorithm| must return a promise. If
+ given, |sizeAlgorithm| must be an algorithm accepting [=chunk=] objects and
+ returning a number; and if given, |highWaterMark| must be a non-negative, non-NaN number.
+
+ 1. Let |startAlgorithm| be an algorithm that returns undefined.
+ 1. Let |closeAlgorithmWrapper| be an algorithm that runs these steps:
+ 1. If |closeAlgorithm| was given, return the result of running it.
+ 1. Return [=a promise resolved with=] undefined.
+ 1. Let |abortAlgorithmWrapper| be an algorithm that runs these steps:
+ 1. If |abortAlgorithm| was given, return the result of running it.
+ 1. Return [=a promise resolved with=] undefined.
+ 1. If |sizeAlgorithm| is not given, then set it to an algorithm that returns 1.
Why is "is not given" present tense when in the previous steps "was given" is past tense?
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1073#pullrequestreview-486354772
Received on Thursday, 10 September 2020 22:51:32 UTC