[whatwg/streams] Be uniformly lenient in what other-spec algorithms can do (#1131)

Previously:

* Setting up a readable stream would ignore the return value (or thrown exception) from pullAlgorithm and sizeAlgorithm, instead always returning an immediately-fulfilled promise.
* Setting up a writable stream would require closeAlgorithm and abortAlgorithm, if given, to return promises.
* Setting up a transform stream would require transformAlgorithm and flushAlgorithm to act synchronously; it would catch any exceptions, but otherwise always return an immediately-fulfilled promise.

Now, all of these algorithms are maximally flexible, to make it easier to write other specs:

* If not given, the wrapper algorithms return immediately-fulfilled promises.
* If they return promises, that promise will be returned, allowing async action. (Web Serial does this currently, even though per the above the Streams spec did not account for it.)
* If they synchronously throw exceptions, those exceptions are converted into rejected promises (and never ignored).
* If they return nothing, i.e. act synchronously, then the wrapper algorithms take care of returning immediately-fulfilled promises.

You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/streams/pull/1131

-- Commit Summary --

  * Be uniformly lenient in what other-spec algorithms can do

-- File Changes --

    M index.bs (38)

-- Patch Links --

https://github.com/whatwg/streams/pull/1131.patch
https://github.com/whatwg/streams/pull/1131.diff

-- 
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/1131

Received on Wednesday, 2 June 2021 22:32:53 UTC