Skip to content

Commit

Permalink
squash! more
Browse files Browse the repository at this point in the history
  • Loading branch information
devsnek authored and MattiasBuelens committed Jan 26, 2019
1 parent f39c70a commit 1eb74e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 19 deletions.
7 changes: 2 additions & 5 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -869,16 +869,13 @@ for="ReadableStreamAsyncIteratorPrototype">return( <var>value</var> )</h4>
<emu-alg>
1. If ! IsReadableStreamAsyncIterator(*this*) is *false*, return <a>a promise rejected with</a> *TypeError* exception.
1. Let _reader_ be *this*.[[asyncIteratorReader]].
1. If _reader_.[[ownerReadableStream]] is *undefined*, return <a>a promise rejected with</a> a *TypeError* exception.
1. If _reader_.[[readRequests]] is not empty, return <a>a promise rejected with</a> a *TypeError* exception.
1. If *this*.[[preventCancel]] is *false*, then:
1. If _reader_.[[ownerReadableStream]] is *undefined*, return <a>a promise rejected with</a> a *TypeError*
exception.
1. If _reader_.[[readRequests]] is not empty, return <a>a promise rejected with</a> a *TypeError* exception.
1. Let _result_ be ! ReadableStreamReaderGenericCancel(_reader_, _value_).
1. Perform ! ReadableStreamReaderGenericRelease(_reader_).
1. Return the result of <a>transforming</a> _result_ by a fulfillment handler that returns !
ReadableStreamCreateReadResult(_value_, *true*, *true*).
1. If _reader_.[[ownerReadableStream]] is *undefined*, return <a>a promise rejected with</a> a *TypeError* exception.
1. If _reader_.[[readRequests]] is not empty, return <a>a promise rejected with</a> a *TypeError* exception.
1. Perform ! ReadableStreamReaderGenericRelease(_reader_).
1. Return <a>a promise resolved with</a> ! ReadableStreamCreateReadResult(_value_, *true*, *true*).
</emu-alg>
Expand Down
21 changes: 7 additions & 14 deletions reference-implementation/lib/readable-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf({
}
const reader = this._asyncIteratorReader;
if (reader._ownerReadableStream === undefined) {
return Promise.reject(readerLockException('next'));
return Promise.reject(readerLockException('iterate'));
}
return ReadableStreamDefaultReaderRead(reader, true);
},
Expand All @@ -189,25 +189,18 @@ const ReadableStreamAsyncIteratorPrototype = Object.setPrototypeOf({
return Promise.reject(streamAsyncIteratorBrandCheckException('next'));
}
const reader = this._asyncIteratorReader;
if (this.preventCancel === false) {
if (reader._ownerReadableStream === undefined) {
return Promise.reject(readerLockException('next'));
}
if (reader._readRequests.length > 0) {
return Promise.reject(new TypeError(
'Tried to release a reader lock when that reader has pending read() calls un-settled'));
}
const result = ReadableStreamReaderGenericCancel(reader, value);
ReadableStreamReaderGenericRelease(reader);
return result.then(() => ReadableStreamCreateReadResult(value, true, true));
}
if (reader._ownerReadableStream === undefined) {
return Promise.reject(readerLockException('next'));
return Promise.reject(readerLockException('finish iterating'));
}
if (reader._readRequests.length > 0) {
return Promise.reject(new TypeError(
'Tried to release a reader lock when that reader has pending read() calls un-settled'));
}
if (this._preventCancel === false) {
const result = ReadableStreamReaderGenericCancel(reader, value);
ReadableStreamReaderGenericRelease(reader);
return result.then(() => ReadableStreamCreateReadResult(value, true, true));
}
ReadableStreamReaderGenericRelease(reader);
return Promise.resolve(ReadableStreamCreateReadResult(value, true, true));
}
Expand Down

0 comments on commit 1eb74e3

Please sign in to comment.