streams icon indicating copy to clipboard operation
streams copied to clipboard

const [ sideA, sideB ] = duplexPair();

Open Johnson1s opened this issue 1 year ago • 2 comments

What is the issue with the Streams Standard?

const [ sideA, sideB ] = duplexPair();

Johnson1s avatar Sep 06 '24 23:09 Johnson1s

Could you elaborate? I cannot identify any action I can take based on the information you have provided.

ricea avatar Sep 09 '24 12:09 ricea

If I had to guess I'd say the ask for a convenience API the essentially implements:

function duplexPair() {
  const {
    readable : r1,
    writable: w1,
  } = new TransformStream();
  const {
    readable: r2,
    writable: w2,
  } = new TransformStream();
  return [
    { readable: r1, writable: w2 },
    { readable: r2, writable: w1 },
  ];
}

But with some additional lifecycle handling that ensures half-open is optionally handled and error state is propagated across the two halves?

Similar to Node.js' equivalent API: https://nodejs.org/docs/latest/api/stream.html#streamduplexpairoptions

jasnell avatar Sep 09 '24 14:09 jasnell