Re: [whatwg/streams] Add a brand check to pipeThrough() (#966)

domenic approved this pull request.

LGTM with nits... will check the tests to ensure they test the changed semantics.

> @@ -661,31 +661,31 @@ option. If <code><a for="underlying source">type</a></code> is set to <code>unde
 </div>
 
 <h5 id="rs-pipe-through" method for="ReadableStream" lt="pipeThrough(transform, options)">pipeThrough({
-<var ignore>writable</var>, <var ignore>readable</var> }, <var ignore>options</var>)</h5>
+<var ignore>writable</var>, <var ignore>readable</var> }, { <var>preventClose</var>, <var>preventAbort</var>,
+<var>preventCancel</var>, <var>signal</var> } = {})</h5>

Also update the class definition to use this style?

> -     values are not permitted.
-     <p class="note"><emu-val>undefined</emu-val> is special-cased here to make it easier to debug errors such as
-     <code>rs.pipeThrough(writable, readable)</code> which otherwise would silently do nothing. <code><a
-     lt="pipeThrough()" for="ReadableStream">pipeThrough()</a></code> is
-     otherwise agnostic about the values that it passes through.</p>
-  1. Let _promise_ be ? Invoke(*this*, `"pipeTo"`, « _writable_, _options_ »).
-  1. If Type(_promise_) is Object and _promise_ has a [[PromiseIsHandled]] internal slot, set
-     _promise_.[[PromiseIsHandled]] to *true*.
+  1. If ! IsReadableStream(*this*) is *false*, throw a *TypeError* exception.
+  1. If ! IsWritableStream(_writable_) is *false*, throw a *TypeError* exception.
+  1. If ! IsReadableStream(_readable_) is *false*, throw a *TypeError* exception
+  1. Set _preventClose_ to ! ToBoolean(_preventClose_), set _preventAbort_ to ! ToBoolean(_preventAbort_), and set
+     _preventCancel_ to ! ToBoolean(_preventCancel_).
+  1. If _signal_ is not *undefined*, and _signal_ is not an instance of the `<a idl>AbortSignal</a>` interface, throw a
+     *TypeError* exception.
+  1. If ! IsReadableStreamLocked(*this*) is *true*, throw a *TypeError* exception.

Interesting that these now throw sync exceptions instead of returning a rejected promise that gets ignored. This is probably the right thing to do...

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/966#pullrequestreview-178333595

Received on Monday, 26 November 2018 15:13:36 UTC