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

前端 未结 3 367
故里飘歌
故里飘歌 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:42

    There are two significant difference between the two. The first is that the util.pump method can operate on two "stream-like" objects, while the Stream.prototype.pipe assumes that they are stream objects. The second is because of that assumption, the pipe can be chained ( streamA | streamB | streamC ) while the former can't (easily).

提交回复
热议问题