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

ShouldCallPull: Assert desiredSize is not null #926

Merged
merged 2 commits into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1826,6 +1826,7 @@ nothrow>ReadableStreamDefaultControllerShouldCallPull ( <var>controller</var> )<
1. If ! IsReadableStreamLocked(_stream_) is *true* and ! ReadableStreamGetNumReadRequests(_stream_) > *0*, return
*true*.
1. Let _desiredSize_ be ReadableStreamDefaultControllerGetDesiredSize(_controller_).
Copy link
Member

Choose a reason for hiding this comment

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

While here can you add a !?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, thanks.

1. Assert: _desiredSize_ is not *null*.
1. If _desiredSize_ > *0*, return *true*.
1. Return *false*.
</emu-alg>
Expand Down Expand Up @@ -2696,7 +2697,9 @@ nothrow>ReadableByteStreamControllerShouldCallPull ( <var>controller</var> )</h4
return *true*.
1. If ! ReadableStreamHasBYOBReader(_stream_) is *true* and ! ReadableStreamGetNumReadIntoRequests(_stream_) > *0*,
return *true*.
1. If ! ReadableByteStreamControllerGetDesiredSize(_controller_) > *0*, return *true*.
1. Let _desiredSize_ be ! ReadableByteStreamControllerGetDesiredSize(_controller_).
1. Assert: _desiredSize_ is not *null*.
1. If _desiredSize_ > *0*, return *true*.
1. Return *false*.
</emu-alg>

Expand Down
5 changes: 4 additions & 1 deletion reference-implementation/lib/readable-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,7 @@ function ReadableStreamDefaultControllerShouldCallPull(controller) {
}

const desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller);
assert(desiredSize !== null);
if (desiredSize > 0) {
return true;
}
Expand Down Expand Up @@ -1708,7 +1709,9 @@ function ReadableByteStreamControllerShouldCallPull(controller) {
return true;
}

if (ReadableByteStreamControllerGetDesiredSize(controller) > 0) {
const desiredSize = ReadableByteStreamControllerGetDesiredSize(controller);
assert(desiredSize !== null);
if (desiredSize > 0) {
return true;
}

Expand Down