Search code examples
javascriptnode.jsstreamevent-stream

What's the difference between event-stream.through and event-stream.map


According to the documentation in event-stream, seems like the difference of this two method is sync or async. But I'm still not sure what the difference really means.


Solution

  • Well, the difference is basically something completely different:

    While the through stream only re-emits, the map stream also is able to modify the data. The first one simply emits what it gets, the data is sent 1:1 to the subscriber. The last one has an additional transformation step, so the data may be 1:1, but does not need to be.

    In other words, the through stream is a kind of identity, while the map is a kind of mapping.