3

Experienced node js devs often recommend to use npm pump module instead of node Stream.pipe method.

Why would I use one instead of the other?

There is a similar looking question in SO but its 6 years old. Its node 9.8.0 already and I guess things changed from that time.

Martin Zinovsky
  • 3,834
  • 2
  • 16
  • 26

2 Answers2

3

TL;DR: use pipeline

As for Node.js 10.x or later version, pipeline is introduced to replace for pump. This is a module method to pipe between streams forwarding errors and properly cleaning up and provide a callback when the pipeline is complete.

But what's the difference between pipe and pipeline? You can find my answer here

Idan Dagan
  • 8,440
  • 4
  • 30
  • 39
0

From the pump README:

When using standard source.pipe(dest) source will not be destroyed if dest emits close or an error. You are also not able to provide a callback to tell when then pipe has finished.

ralphtheninja
  • 117,827
  • 20
  • 105
  • 119