PassThrough Streams

Learn about PassThrough streams, observability, and how to implement late piping and lazy stream patterns.

There’s a fifth type of stream that’s worth mentioning and it’s called a PassThrough stream. This type of stream is a special type of Transform stream that outputs every data chunk without applying any transformation.

PassThrough is possibly the most underrated type of stream, but there are actually several circumstances in which it can be a very valuable tool in our toolkit. For instance, PassThrough streams can be useful for observability or for implementing late piping and lazy stream patterns.

Observability

If we want to observe how much data is flowing through one or more streams, we can do so by attaching a data event listener to a PassThrough instance and then piping this instance in a given point of a stream pipeline. Let’s look at a simplified example to be able to appreciate this concept.

Get hands-on with 1400+ tech skills courses.