Rewrite ReadableStream.tee() using the public API #98
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We want to make the polyfill compatible with native
ReadableStream
objects (#20), e.g. fromnew Response().body
in the browser or fromReadable.toWeb()
in Node.js. In order to get there, the polyfill must implement all of its utility methods using the public API ofReadableStream
(e.g.reader.read()
) rather than using its own internal abstract operations (e.g.ReadableStreamDefaultReaderRead()
).This PR handles
ReadableStream.tee()
. We'll want to do the same withpipeTo()
,pipeThrough()
,[Symbol.asyncIterator]()
etc in follow-up PRs.Since we now use
reader.read()
internally, we no longer pass the "patched global" tests. For example, the{ done, value }
object returned byreader.read()
can now have a.then()
method if the user definesObject.prototype.then()
. I think this is fine though. These tests are intended for browser implementations to ensure user-land code cannot affect the internals ofpipeTo()
andtee()
, but I think it's unreasonable to expect a user-land polyfill to try and isolate itself from other user-land code messing with the globalObject.prototype
.This PR also sets up some infrastructure to skip specific tests within a WPT test file. We already have logic to skip an entire test file, but often there's just one single problematic test that we can't run (e.g. because it causes the test to hang). Now, we can replace these individual tests with a dummy that fails immediately, and still run all the other tests in the file. We'll need this when we rewrite e.g.
pipeTo()
.