Transform and Duplex Stream

In notebook:
FrontEndMasters Networking and Streams
Created at:
2017-09-24
Updated:
2017-09-24
Tags:
backend Node JS JavaScript

have all the methods of readable and writeable, and their events. you put them in between two other streams.

transform

readable + writable stream where:

input -> transform -> output

All the readable AND writable methods are available.


duplex

imagine a separate writable and readable stream but glued together into the same stream instance. Like a telephone. Both sides can talk the same time.

readable + writable stream where input is decoupled from output

like a telephone!

input -> duplex
duplex -> output

All the readable AND writable methods are available.


duplex

If you see:

a.pipe(stream).pipe(a)

then you are dealing with a duplex stream.

Examples

If you create a TCP server in NodeJS with net.server or net.connect