![]() ![]() Open Node.js command prompt and run the following code:Ĭ:\Users\FileOpearation\Desktop>node zlib_example1.js We have a text file named "test.txt" on the desktop. const out = fs.createWriteStream( '' ).const inp = fs.createReadStream( 'test.txt' ).Let's see a simple example of Node.js ZLIB module to compress a file "test.txt" into "". Go to project location where you add zlib_example1.js fileĬommand - node zlib_example1.js press enter Node.js ZLIB Example: Compress File.Please set up a node js project in your system.To Run the below sample codes for compress and Decompress The zlib module can be accessed using: const zlib = require (' zlib ' ) Ĭompressing and decompressing a file can be done by piping the source stream data into a destination stream through zlib stream. It is implemented using Gzip and deflate/inflate. Zlib - The Node.js Zlib module is used to provide compression and decompression (zip and unzip) functionalities. Lossy compression algorithms reduce the size of files by discarding the less important information in a file, which can significantly reduce file size but also affect file quality. ![]() Lossless compression algorithms reduce the size of files without losing any information in the file, which means that we can reconstruct the original data from the compressed file. There are two types of compression: lossless and lossy. Thus, the process of reducing the amount of data required to represent information is called compression. This results in a reduction in the time needed for file transfer as well as a reduction in the bandwidth utilization even for a slow network. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |