Re: [whatwg/streams] Allow web devs to synchronize branches with tee()? (#1157)

> But as soon as a frame is enqueued onto the stream it becomes part of this "logical concatenation" and mustn't be dropped by a branch from `tee()`, no matter how fast/slow the branch is being consumed. That is, this should _always_ be true:
> 
> ```js
> const [branch1, branch2] = readable.tee();
> let chunks1 = [];
> let chunks2 = [];
> for await (let chunk of branch1) chunks1.push(chunk);
> for await (let chunk of branch2) chunks2.push(chunk);
> chunks1.forEach((chunk, i) => chunk === chunks2[i]);
> ```

Agreed, and this would remain true, because I'm not suggesting `tee({synchronized: true})` drop chunks, merely that it keep the branches in lockstep, which is desirable for expensive chunks (bikeshed: maybe `tee({lockstep: true})` is better?)

I don't believe there's any requirement on transforms to produce the same number of chunks they consume. [E.g.](https://jsfiddle.net/jib1/8kdn3beh/20/)

Apart from `tee`, the streams spec doesn't seem to rule out real-time streams (even defaulting highWaterMarks to 1).

> Looks like you're running into much of the same issues [as WebCodecs did](https://github.com/w3c/webcodecs/blob/a044235116df03f3a97f574a1a546e45eff26346/explainer.md#integrating-with-whatwg-streams). 😕

Where does that document mention this issue?

-- 
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/1157#issuecomment-893480503

Received on Thursday, 5 August 2021 13:56:24 UTC