...

/

Writable Streams: Implementation

Writable Streams: Implementation

Learn to implement Writable streams.

Implementing Writable streams

We can implement a new Writable stream by inheriting the Writable class and providing an implementation for the _write() method. Let’s try to do it immediately while discussing the details along the way.
First, let’s build a Writable stream that receives objects in the following format:

{
path: <path to a file>
content: <string or buffer>
}

For each objects, our stream has to save the content property into a file created at the given path. We can immediately see that the inputs of our stream ...