Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add IsReadableStreamDisturbed predicate #385

Merged
merged 4 commits into from
Aug 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 32 additions & 49 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ Instances of <code>ReadableStream</code> are created with the internal slots des
<td>A <a href="#rs-controller-class"><code>ReadableStreamController</code></a> created with the ability to control the
state and queue of this stream
</tr>
<tr>
<td>\[[disturbed]]
<td>A boolean flag set to <b>true</b> when the stream has been read from or canceled
</tr>
<tr>
<td>\[[pullAgain]]
<td>A boolean flag set to <b>true</b> if the stream's mechanisms requested a call to the underlying source's
Expand Down Expand Up @@ -398,6 +402,7 @@ Instances of <code>ReadableStream</code> are created with the internal slots des
1. Set *this*@[[state]] to "readable".
1. Set *this*@[[started]], *this*@[[closeRequested]], *this*@[[pullAgain]], and *this*@[[pulling]] to *false*.
1. Set *this*@[[reader]] and *this*@[[storedError]] to *undefined*.
1. Set *this*@[[disturbed]] to *false*.
1. Set *this*@[[controller]] to Construct(`ReadableStreamController`, «*this*»).
1. Let _normalizedStrategy_ be ValidateAndNormalizeQueuingStrategy(_size_, _highWaterMark_).
1. Set *this*@[[strategySize]] to _normalizedStrategy_.[[size]] and *this*@[[strategyHWM]] to _normalizedStrategy_.[[highWaterMark]].
Expand Down Expand Up @@ -745,16 +750,6 @@ Instances of <code>ReadableStreamReader</code> are created with the internal slo
<td>A List of promises returned by calls to the reader's <code>read()</code> method that have not yet been resolved,
due to the <a>consumer</a> requesting <a>chunks</a> sooner than they are available
</tr>
<tr>
<td>\[[state]]
<td>A string containing the reader's current state, used internally; one of <code>"readable"</code>,
<code>"closed"</code>, or <code>"errored"</code>
</tr>
<tr>
<td>\[[storedError]]
<td>A value indicating how the reader's stream failed, to be given as a failure reason or exception when trying to
operate on the reader; applicable only when \[[state]] is <code>"errored"</code>
</tr>
</table>

<h4 id="reader-constructor">new ReadableStreamReader(stream)</h4>
Expand All @@ -768,21 +763,15 @@ Instances of <code>ReadableStreamReader</code> are created with the internal slo
<emu-alg>
1. If IsReadableStream(_stream_) is *false*, throw a *TypeError* exception.
1. If IsReadableStreamLocked(_stream_) is *true*, throw a *TypeError* exception.
1. Set *this*@[[state]] to _stream_@[[state]].
1. Set *this*@[[readRequests]] to a new empty List.
1. Set *this*@[[ownerReadableStream]] to _stream_.
1. Set _stream_@[[reader]] to *this*.
1. If _stream_@[[state]] is "readable",
1. Set *this*@[[ownerReadableStream]] to _stream_.
1. Set *this*@[[storedError]] to *undefined*.
1. Set *this*@[[closedPromise]] to a new promise.
1. Set _stream_@[[reader]] to *this*.
1. Otherwise, if _stream_@[[state]] is "closed",
1. Set *this*@[[ownerReadableStream]] to *undefined*.
1. Set *this*@[[storedError]] to *undefined*.
1. Set *this*@[[closedPromise]] to a new promise resolved with *undefined*.
1. Otherwise,
1. Assert: _stream_@[[state]] is "errored".
1. Set *this*@[[ownerReadableStream]] to *undefined*.
1. Set *this*@[[storedError]] to _stream_@[[storedError]].
1. Set *this*@[[closedPromise]] to a new promise rejected with _stream_@[[storedError]].
</emu-alg>

Expand All @@ -809,10 +798,7 @@ Instances of <code>ReadableStreamReader</code> are created with the internal slo

<emu-alg>
1. If IsReadableStreamReader(*this*) is *false*, return a promise rejected with a *TypeError* exception.
1. If *this*@[[state]] is "closed", return a new promise resolved with *undefined*.
1. If *this*@[[state]] is "errored", return a new promise rejected with *this*@[[storedError]].
1. Assert: *this*@[[ownerReadableStream]] is not *undefined*.
1. Assert: *this*@[[ownerReadableStream]]@[[state]] is "readable".
1. If *this*@[[ownerReadableStream]] is *undefined*, return a promise rejected with a *TypeError* exception.
1. Return CancelReadableStream(*this*@[[ownerReadableStream]], _reason_).
</emu-alg>

Expand All @@ -835,6 +821,7 @@ Instances of <code>ReadableStreamReader</code> are created with the internal slo

<emu-alg>
1. If IsReadableStreamReader(*this*) is *false*, return a promise rejected with a *TypeError* exception.
1. If *this*@[[ownerReadableStream]] is *undefined*, return a promise rejected with a *TypeError* exception.
1. Return ReadFromReadableStreamReader(*this*).
</emu-alg>

Expand All @@ -855,7 +842,10 @@ Instances of <code>ReadableStreamReader</code> are created with the internal slo
1. If IsReadableStreamReader(*this*) is *false*, throw a *TypeError* exception.
1. If *this*@[[ownerReadableStream]] is *undefined*, return *undefined*.
1. If *this*@[[readRequests]] is not empty, throw a *TypeError* exception.
1. Perform CloseReadableStreamReader(*this*).
1. If *this*@[[ownerReadableStream]]@[[state]] is `"readable"`, reject *this*@[[closedPromise]] with a *TypeError* exception.
1. Otherwise, set *this*@[[closedPromise]] be a new promise rejected with a *TypeError* exception.
1. Set *this*@[[ownerReadableStream]]@[[reader]] to *undefined*.
1. Set *this*@[[ownerReadableStream]] to *undefined*.
1. Return *undefined*.
</emu-alg>

Expand All @@ -873,6 +863,7 @@ reader</a> for a given stream.
<h4 id="cancel-readable-stream" aoid="CancelReadableStream" nothrow>CancelReadableStream ( stream, reason )</h4>

<emu-alg>
1. Set _stream_@[[disturbed]] to *true*.
1. If _stream_@[[state]] is "closed", return a new promise resolved with *undefined*.
1. If _stream_@[[state]] is "errored", return a new promise rejected with _stream_@[[storedError]].
1. Set _stream_@[[queue]] to a new empty List.
Expand Down Expand Up @@ -904,18 +895,6 @@ this to streams they did not create, and must ensure they have obeyed the precon
control of the underlying source.
</div>

<h4 id="close-readable-stream-reader" aoid="CloseReadableStreamReader" nothrow>CloseReadableStreamReader ( reader )</h4>

<emu-alg>
1. Repeat for each _readRequestPromise_ that is an element of _reader_@[[readRequests]],
1. Resolve _readRequestPromise_ with CreateIterResultObject(*undefined*, *true*).
1. Set _reader_@[[readRequests]] to an empty List.
1. Perform ReleaseReadableStreamReader(_reader_).
1. Set _reader_@[[state]] to "closed".
1. Resolve _reader_@[[closedPromise]] with *undefined*.
1. Return *undefined*.
</emu-alg>

<h4 id="enqueue-in-readable-stream" aoid="EnqueueInReadableStream" throws>EnqueueInReadableStream ( stream, chunk )</h4>

This abstract operation can be called by other specifications that wish to enqueue <a>chunks</a> in a readable stream,
Expand Down Expand Up @@ -972,9 +951,6 @@ an assert).
1. Repeat for each _readRequestPromise_ that is an element of _reader_@[[readRequests]],
1. Reject _readRequestPromise_ with _e_.
1. Set _reader_@[[readRequests]] to a new empty List.
1. Perform ReleaseReadableStreamReader(_reader_).
1. Set _reader_@[[storedError]] to _e_.
1. Set _reader_@[[state]] to "errored".
1. Reject _reader_@[[closedPromise]] with _e_.
1. Return *undefined*.
</emu-alg>
Expand All @@ -985,7 +961,11 @@ an assert).
1. Assert: _stream_@[[state]] is "readable".
1. Set _stream_@[[state]] to "closed".
1. Let _reader_ be _stream_@[[reader]].
1. If _reader_ is not *undefined*, perform CloseReadableStreamReader(_reader_).
1. If _reader_ is *undefined*, return *undefined*.
1. Repeat for each _readRequestPromise_ that is an element of _reader_@[[readRequests]],
1. Resolve _readRequestPromise_ with CreateIterResultObject(*undefined*, *true*).
1. Set _reader_@[[readRequests]] to an empty List.
1. Resolve _reader_@[[closedPromise]] with *undefined*.
1. Return *undefined*.
</emu-alg>

Expand All @@ -1012,6 +992,16 @@ an assert).
1. Return *true*.
</emu-alg>

<h4 id="is-readable-stream-disturbed" aoid="IsReadableStreamDisturbed" nothrow>IsReadableStreamDisturbed ( stream )</h4>

This abstract operation is meant to be called from other specifications that may wish to query whether or not a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"...readable stream has ever been read from or canceled"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

readable stream has ever been read from or canceled.

<emu-alg>
1. Assert: IsReadableStream(_stream_) is *true*.
1. Return _stream_@[[disturbed]].
</emu-alg>

<h4 id="is-readable-stream-locked" aoid="IsReadableStreamLocked" nothrow>IsReadableStreamLocked ( stream )</h4>

This abstract operation is meant to be called from other specifications that may wish to query whether or not a
Expand All @@ -1034,9 +1024,10 @@ readable stream is <a>locked to a reader</a>.
<h4 id="read-from-readable-stream-reader" aoid="ReadFromReadableStreamReader" nothrow>ReadFromReadableStreamReader ( reader )</h4>

<emu-alg>
1. If _reader_@[[state]] is "closed", return a new promise resolved with CreateIterResultObject(*undefined*, *true*).
1. If _reader_@[[state]] is "errored", return a new promise rejected with _reader_@[[storedError]].
1. Assert: _reader_@[[ownerReadableStream]] is not *undefined*.
1. Set _reader_@[[ownerReadableStream]]@[[disturbed]] to *true*.
1. If _reader_@[[ownerReadableStream]]@[[state]] is "closed", return a new promise resolved with CreateIterResultObject(*undefined*, *true*).
1. If _reader_@[[ownerReadableStream]]@[[state]] is "errored", return a new promise rejected with _reader_@[[ownerReadableStream]]@[[storedError]].
1. Assert: _reader_@[[ownerReadableStream]]@[[state]] is "readable".
1. If _reader_@[[ownerReadableStream]]@[[queue]] is not empty,
1. Let _chunk_ be DequeueValue(_reader_@[[ownerReadableStream]]@[[queue]]).
Expand All @@ -1050,14 +1041,6 @@ readable stream is <a>locked to a reader</a>.
1. Return _readRequestPromise_.
</emu-alg>

<h4 id="release-readable-stream-reader" aoid="ReleaseReadableStreamReader" nothrow>ReleaseReadableStreamReader ( reader )</h4>

<emu-alg>
1. Assert: _reader_@[[ownerReadableStream]] is not *undefined*.
1. Set _reader_@[[ownerReadableStream]]@[[reader]] to *undefined*.
1. Set _reader_@[[ownerReadableStream]] to *undefined*.
</emu-alg>

<h4 id="request-readable-stream-pull" aoid="RequestReadableStreamPull" nothrow>RequestReadableStreamPull ( stream )</h4>

<emu-alg>
Expand Down
Loading