December 2018
Intermediate to advanced
642 pages
15h 5m
English
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.jsconst zlib = require("zlib");const fs = require("fs");const inputStream = fs.createReadStream( "/home/fkereki/Documents/CHURCHES - Digital Taxonomy.pdf");const gzipStream = zlib.createGzip();const outputStream = fs.createWriteStream( "/home/fkereki/Documents/CHURCHES.gz");inputStream.pipe(gzipStream).pipe(outputStream);
Read now
Unlock full access