A stream that produces output. A one way interface, like a radio.
,----stream---------
user<---|emits 'data', 'end'
|
|
`-------------------
A stream that accepts input. A one way interface, like a tape-recorder.
,----stream---------
user--->|write(), end()
|
|
`-------------------
A stream that transforms input into output.
A through stream is like a meat grinder.
Mince comes out, but only when you put something in.
user--,
|
v
,-------------------.
| write(), end() |
| |
|emits 'end', 'data'|
`-------------------`
|
|
user<-`
A stream that enables two-way communication with some remote/complex object.
A duplex stream is like a telephone.
Although your speech may be a reaction to mine,
it is also the result of the crazy workings of your own brain,
and the strange things you are looking at and smelling.
It is important to understand the difference between a through stream, and a duplex stream.
|
,--------------------,
| |
user ------->| write(), end() ======> S O M E
| |
| | T H I N G
user <-------|emits 'data', 'end' <==
| | E L S E
`--------------------`
|
A duplex stream is also used to give a single interface for two other streams. For example a player is a duplex of a writable UI widget and a readable keyboard input stream.
I think remote/complex vs joining two streams together is an important distinquishion.