poelstra / ts-stream

Type-safe object streams with seamless support for backpressure, ending, and error handling
MIT License
65 stars 13 forks source link

stream.Duplex does not seem to implemented #41

Closed Yugloocamai closed 4 years ago

Yugloocamai commented 5 years ago

is that planned?

poelstra commented 5 years ago

It is not planned, no.

Main reason is that I found Duplex to be a bit 'confusing', at least in the typical transform-pipeline scenarios where ts-stream is applied. Like a Stream, it has a readable and writable interface, yet these interfaces belong to different streams. In cases where I wanted to represent a pair of streams like this, I explicitly placed these two streams as properties in an object (a bit similar to how stdin and stdout are treated separately, I suppose).

interface Duplex {
  input: Stream;
  output: Stream;
};

(You could choose names that better work for your domain, like upstream/downstream, left/right, etc)

Also, I didn't really have a need for Duplex that much yet (typically 'splitting' a Duplex right at its source), but I'm open for ideas.