Compressing and Decompressing Buffers
The Zlib
module provides several helper functions that make it easy to compress/decompress data buffers. They all use the same basic format of function(buffer, callback), where function is the compression/decompression method, buffer is the buffer to be compressed/decompressed, and callback is the callback function that is executed after the compression/decompression occurs.
The simplest way to illustrate buffer compression/decompression is to show you some examples. The code in Listing 5.11 provides several compression/decompression examples and outputs the size results of each as shown in Figure 5.11.
Get Node.js, MongoDB, and AngularJS Web Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.