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 fast path for ReadableStream.from(readableStream) #135

Merged
merged 8 commits into from
Jan 4, 2024

Conversation

MattiasBuelens
Copy link
Owner

ReadableStream.from() usually requires its argument to be an iterable or an async iterable. However, async iteration over a native ReadableStream is not yet well supported in browsers, so it cannot be used to convert a native stream to a polyfill stream.

This adds a fast path for converting anything that "looks like" a ReadableStream to a polyfill ReadableStream:

  • The stream must have a getReader() method, which must return a default reader.
  • The default reader must have read() and cancel() methods.

Fixes #1

@MattiasBuelens MattiasBuelens added this to the v3.3.0 milestone Jan 4, 2024
@MattiasBuelens MattiasBuelens merged commit e41321b into master Jan 4, 2024
5 checks passed
@MattiasBuelens MattiasBuelens deleted the optimize-rs-from branch January 4, 2024 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert from/to native streams?
1 participant