2

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,390
  • 1
  • 15
  • 24

2 Answers2

2

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
  • 6,637
  • 3
  • 26
  • 37
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
  • 107,622
  • 20
  • 101
  • 118