Exercise: Data Compression Efficiency
Explore how to write a command-line script that compresses files using Brotli, Deflate, and Gzip algorithms from the Node.js zlib module. Learn to measure and compare the compression time and efficiency of each method by working with streams and implementing timing functionality. Understand the practical application of streams and asynchronous control flow in Node.js through a coding exercise that develops skills in efficient data compression.
We'll cover the following...
Problem statement
Write a command-line script that takes a file as input and compresses it using the different algorithms available in the zlib module (Brotli, Deflate, Gzip). You want to produce a summary table that compares the algorithm’s compression time and compression efficiency on the given file.
If you’re unsure about how to do this, click the “Show Hint” button.
Coding challenge
Write your solution code in the following code widget. We’ve ...