NodeJS: What's the difference between a Duplex stream and a Transform stream?

后端 未结 4 1683
忘掉有多难
忘掉有多难 2020-12-23 11:53

The Stream docs state that Duplex Streams \"are streams that implement both the Readable and Writable interfaces\" and Transform Streams \"are Duplex streams where the outpu

4条回答
  •  甜味超标
    2020-12-23 12:34

    The difference is just syntactic sugar. Transform streams are full duplex streams but rather than implementing _write and _read methods, you are asked to implement just the _transform method. You can read more about streams on the excellent substack's streams guide or from Isaacs's readable-stream repo.

提交回复
热议问题