The Consuming streams and Playing with pipes recipes show us how to initiate and interact with various stream interfaces, such as the
fs module's read and write streams, the
response object's write stream, and third-party modules, such as
JSONStream (refer to the There's More… section of Playing with pipes).
In this recipe, we're going to make our own basic read and write stream interfaces.
Let's create and open a file, which we'll name
stream module contains some base constructors to create streams. So, let's require the
stream module and instantiate a readable stream as well as a writable stream:
var stream = require('stream'); var writable = new stream.Writable(); ...