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
  • 4,042
  • 2
  • 19
  • 29
  • 1
    The old SO question is about `pump` which is completely unrelated to the module `pump` (by mafintosh). – rtn Mar 16 '18 at 13:20

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
  • 10,273
  • 5
  • 34
  • 41
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.

rtn
  • 127,556
  • 20
  • 111
  • 121