[whatwg/streams] pipeThrough(): complain about undefined args? (#756)

Currently, according to the standard, `rs.pipeThrough({})` should do nothing. More precisely, `pipeTo()` will return a rejection which `pipeThrough()` will mark as handled and ignore.

This makes it hard to spot mistakes: if you write `rs.pipeThrough(writable, readable)` (ie. you miss off the `{}`) it will do nothing at all.

See https://github.com/whatwg/streams/issues/754 which brought this usability issue to my attention.

I am currently thinking that in order to make it easier to use we should special-case undefined values and throw an exception. I think we don't need to cater to values of `this` for which `pipeTo(undefined)` is a useful expression. Similarly, while returning `undefined` when `readable` wasn't specified is what the user asked for, it's unlikely to be what they meant.

This change would be pretty backwards compatible: we'd be changing behaviour that is useless anyway, and both Chrome and Safari currently throw a TypeError for an undefined `writable` (in Chrome's case this was a mistake). Useful uses of `pipeThrough()` would be interoperable between implementations with and without the change.

-- 
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/issues/756

Received on Monday, 24 July 2017 14:21:12 UTC