[whatwg/streams] Editorial: use dictionaries for { value, done } and eliminate "forAuthorCode"? (#1036)

After #1035 lands, I think it might be possible to go further.

In particular, I'm hoping to clean up the return type of `read()` to be a dictionary with `value` and `done` members.

But while looking into this, I'm noodling on ways to clean up the whole "forAuthorCode" business. Is there a way we can keep the internals of the stream agnostic to the JS object format, and only convert the chunks/end-of-stream signals into dictionaries (and then via Web IDL, JS objects) at the end?

The difficult part of this is that the internals of the streams seem bound up in the promise machinery, and promises are fundamentally resolved with JS values. Maybe we could resolve those promises with JS values for the chunks, and have a special JS value representing end-of-stream, instead of having to create prototype-pollution-prone `{ value, done }` objects and then potentially null out their prototype?

I think it's also worth figuring out what the best interface is for other specifications. If we could avoid them having to deal with raw promises for `{ value, done }` objects, that would be a plus.

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

Received on Tuesday, 19 May 2020 21:05:38 UTC