What is the difference between util.pump(streamA, streamB) and streamA.pipe(streamB)?

前端 未结 3 369
故里飘歌
故里飘歌 2021-01-12 22:10

The source code looks very similar: pump, pipe. Why would I use one instead of the other? Is one simply a better version of the other?

3条回答
  •  悲哀的现实
    2021-01-12 22:43

    UPDATE: 28/04/2020

    It's worth to say that pump is only necessary for Node.js 8.x or earlier, 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.

提交回复
热议问题