Compression and decompression of data using zlib in Nodejs
问题 Can someone please explain to me how the zlib library works in Nodejs? I'm fairly new to Nodejs, and I'm not yet sure how to use buffers and streams. My simple scenario is a string variable, and I want to either zip or unzip (deflate or inflate, gzip or gunzip, etc') the string to another string. I.e. (how I would expect it to work) var zlib = require('zlib'); var str = "this is a test string to be zipped"; var zip = zlib.Deflate(str); // zip = [object Object] var packed = zip.toString(