1

Node.js has an internal implementation of Duplex Streams, defined as:

Duplex streams are streams that implement both the Readable and Writable interfaces.

There is a widely popular package called Duplexify: https://github.com/mafintosh/duplexify

Its functionality is defined as

Turn a writeable and readable stream into a single streams2 duplex stream. Similar to duplexer2 except it supports both streams2 and streams1 as input and it allows you to set the readable and writable part asynchronously using setReadable(stream) and setWritable(stream)

It is not initially clear if duplexify is an outdated package, or if it provides additional features that the built in Duplex streams do not provide.

How is duplexify different from the node.js internal Duplex Stream, and what use cases warrant Duplex Stream vs. duplexify

yodama
  • 659
  • 1
  • 9
  • 21
  • Actually, the streams2 and streams1 and streams3 referenced by duplexer2 and duplexify refers to versions of node.js internal streams. So duplexify converts node.js internal read and write streams to a single node.js internal duplex stream – slebetman May 08 '20 at 06:16
  • @slebetman that suggests that duplexify is an unnecessary package then, since that is essentially what the built-in "Duplex" stream does in Node.js – yodama Aug 14 '20 at 18:36
  • 2
    Duplexify converts seperated (non-duplex) internal Node.js streams such as stdin (non-duplex input stream) and stdout (non-duplex output stream) into internal Node.js duplex stream. Doing this yourself will require writing extra code (piping input or handling onData event and piping output or handling writes yourself) which is what duplexify tries to simplify by just passing the two streams into it – slebetman Aug 17 '20 at 07:40

0 Answers0