Skip to content

Commit

Permalink
Merge pull request #21 from MattiasBuelens/update-20190401
Browse files Browse the repository at this point in the history
Update to spec version of 1 April 2019
  • Loading branch information
MattiasBuelens committed Apr 4, 2019
2 parents 505f727 + c2238c9 commit c1eca60
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
## Unreleased

* 👓 Align with [spec version `6f94580`](https://github.com/whatwg/streams/tree/6f94580f6731d1e017c516af097d47c45aad1f56/)
* 🏠 Run web platform tests on ES5 variant ([#19](https://github.com/MattiasBuelens/web-streams-polyfill/pull/19))

## v2.0.2 (2019-03-17)
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The `polyfill/es2018` and `ponyfill/es2018` variants work in any ES2018-compatib

### Compliance

The polyfill implements [version `2c8f35e` (21 Feb 2019)][spec-snapshot] of the streams specification.
The polyfill implements [version `6f94580` (1 Apr 2019)][spec-snapshot] of the streams specification.

The polyfill is tested against the same [web platform tests][wpt] that are used by browsers to test their native implementations.
The polyfill aims to pass all tests, although it allows some exceptions for practical reasons:
Expand Down Expand Up @@ -99,12 +99,12 @@ Thanks to these people for their work on [the original polyfill][creatorrr-polyf
[promise-support]: https://kangax.github.io/compat-table/es6/#test-Promise
[promise-polyfill]: https://www.npmjs.com/package/promise-polyfill
[rs-asynciterator]: https://streams.spec.whatwg.org/#rs-asynciterator
[spec-snapshot]: https://streams.spec.whatwg.org/commit-snapshots/2c8f35ed23451ffc9b32ec37b56def4a5349abb1/
[wpt]: https://github.com/web-platform-tests/wpt/tree/de6f8fcf9b87e80811e9267a886cf891f6f864e0/streams
[wpt-detached-buffer]: https://github.com/web-platform-tests/wpt/blob/de6f8fcf9b87e80811e9267a886cf891f6f864e0/streams/readable-byte-streams/detached-buffers.any.js
[spec-snapshot]: https://streams.spec.whatwg.org/commit-snapshots/6f94580f6731d1e017c516af097d47c45aad1f56/
[wpt]: https://github.com/web-platform-tests/wpt/tree/05e7031bec9a03261cbf112b575a7998b7c76b3c/streams
[wpt-detached-buffer]: https://github.com/web-platform-tests/wpt/blob/05e7031bec9a03261cbf112b575a7998b7c76b3c/streams/readable-byte-streams/detached-buffers.any.js
[proposal-arraybuffer-transfer]: https://github.com/domenic/proposal-arraybuffer-transfer
[ref-impl-transferarraybuffer]: https://github.com/whatwg/streams/blob/2c8f35ed23451ffc9b32ec37b56def4a5349abb1/reference-implementation/lib/helpers.js#L119
[ref-impl-transferarraybuffer]: https://github.com/whatwg/streams/blob/6f94580f6731d1e017c516af097d47c45aad1f56/reference-implementation/lib/helpers.js#L119
[issue-3]: https://github.com/MattiasBuelens/web-streams-polyfill/issues/3
[wpt-async-iterator-prototype]: https://github.com/web-platform-tests/wpt/blob/de6f8fcf9b87e80811e9267a886cf891f6f864e0/streams/readable-streams/async-iterator.any.js#L17
[wpt-async-iterator-prototype]: https://github.com/web-platform-tests/wpt/blob/05e7031bec9a03261cbf112b575a7998b7c76b3c/streams/readable-streams/async-iterator.any.js#L17
[stub-async-iterator-prototype]: https://github.com/MattiasBuelens/web-streams-polyfill/blob/v2.0.0/src/target/es5/stub/async-iterator-prototype.ts
[creatorrr-polyfill]: https://github.com/creatorrr/web-streams-polyfill
19 changes: 13 additions & 6 deletions src/lib/readable-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ function ReadableStreamTee<R>(stream: ReadableStream<R>,

const reader = AcquireReadableStreamDefaultReader<R>(stream);

let closed = false;
let reading = false;
let canceled1 = false;
let canceled2 = false;
let reason1: any;
Expand All @@ -670,10 +670,14 @@ function ReadableStreamTee<R>(stream: ReadableStream<R>,
});

function pullAlgorithm(): Promise<void> {
return ReadableStreamDefaultReaderRead(reader).then(result => {
if (closed === true) {
return;
}
if (reading === true) {
return Promise.resolve();
}

reading = true;

const readPromise = ReadableStreamDefaultReaderRead(reader).then(result => {
reading = false;

assert(typeIsObject(result));
const done = result.done;
Expand All @@ -686,7 +690,6 @@ function ReadableStreamTee<R>(stream: ReadableStream<R>,
if (canceled2 === false) {
ReadableStreamDefaultControllerClose(branch2._readableStreamController as ReadableStreamDefaultController<R>);
}
closed = true;
return;
}

Expand Down Expand Up @@ -714,6 +717,10 @@ function ReadableStreamTee<R>(stream: ReadableStream<R>,
);
}
});

readPromise.catch(rethrowAssertionErrorRejection);

return Promise.resolve();
}

function cancel1Algorithm(reason: any): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion test/web-platform-tests

0 comments on commit c1eca60

Please sign in to comment.