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 an abstraction to pull from buffer into ReadableStream #1263

Merged
merged 7 commits into from
Apr 5, 2023
Merged
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
10 changes: 7 additions & 3 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -6784,9 +6784,13 @@ They should only [=ArrayBufferView/create=] a new {{ArrayBufferView}} to pass to
[=ReadableStream/enqueue=] when the [=ReadableStream/current BYOB request view=] is null, or when
they have more bytes on hand than the [=ReadableStream/current BYOB request view=]'s
Copy link
Member Author

@saschanaz saschanaz Apr 3, 2023

Choose a reason for hiding this comment

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

Should we explicitly say the below algorithm doesn't enqueue "when they have more bytes on hand than ..."?

Also, w3c/webtransport#487 throws in that case, should it enqueue instead? Not sure it's fine to implicitly ignore the byob request view. Oh okay, it doesn't match what it wants in that case.

Copy link
Member

Choose a reason for hiding this comment

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

Added a note, thanks!

[=BufferSource/byte length=]. This avoids unnecessary copies and better respects the wishes of the
stream's [=consumer=]. The following [=ReadableStream/pull from bytes=] algorithm implements these
requirements, for the common case where bytes are derived from a [=byte sequence=] that serves as
the specification-level representation of an [=underlying byte source=].
stream's [=consumer=].

The following [=ReadableStream/pull from bytes=] algorithm implements these requirements, for the
common case where bytes are derived from a [=byte sequence=] that serves as the specification-level
representation of an [=underlying byte source=]. Note that it is conservative and leaves bytes in
the [=byte sequence=], instead of aggressively [=ReadableStream/enqueueing=] them, so callers of
this algorithm might want to use the number of remaining bytes as a [=backpressure=] signal.

<div algorithm>
To <dfn export for="ReadableStream">pull from bytes</dfn> with a [=byte sequence=] |bytes| into a
Expand Down