We can see more examples of using streams, of several types, such as in cases where we wanted to zip a file. In this recipe, we will be using a readable stream to read from a source, and a writable stream to put the zipped result.
Compressing files with streams
How to do it...
The code is quite straightforward, and short, too. We just have to require the needed modules, create an input stream for the file that we'll read, an output stream for the file that we'll create, and pipe the first stream to the second one; nothing could be simpler:
// Source file: src/zip_files.js
const zlib = require("zlib");
const fs = require("fs");
const inputStream = fs.createReadStream(
"/home/fkereki/Documents...