util.pump(streamA,streamB)和streamA.pipe(streamB)有什么区别?

源代码看起来非常相似: pumppipe 。 为什么我会使用一个而不是另一个? 一个只是另一个更好的版本?

Stream.pipe现在是0.3.x以后的首选方法,所以尽可能使用它

来源:

https://groups.google.com/forum/?fromgroups#!topic/nodejs/FwdDQvAf4xM

https://stackoverflow.com/a/4591335/424851

两者有两个显着的区别。 首先, util.pump方法可以在两个“类stream”对象上运行,而Stream.prototype.pipe假定它们stream对象。 第二个是因为这个假设, pipe可以被链接( streamA | streamB | streamC ),而前者不能(很容易)。