Created
October 16, 2012 02:53
Revisions
-
coryvirok renamed this gist
Oct 16, 2012 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ var zlib = require('zlib'); var plaintext = 'Hello World'; @@ -23,4 +22,3 @@ compressor.on('end', function() { console.log(decompressedData.join('')); }); }); -
coryvirok revised this gist
Oct 16, 2012 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ ```javascript var zlib = require('zlib'); var plaintext = 'Hello World'; @@ -21,4 +22,5 @@ compressor.on('end', function() { decompressor.on('end', function() { console.log(decompressedData.join('')); }); }); ``` -
coryvirok created this gist
Oct 16, 2012 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ var zlib = require('zlib'); var plaintext = 'Hello World'; var compressedData = []; var compressor = zlib.createGzip(); compressor.write(plaintext); compressor.end(); compressor.on('data', function(d) { compressedData.push(d);}); compressor.on('end', function() { var b64CompressedData = new Buffer(compressedData.join('')).toString('base64'); var b64CompressedBuf = new Buffer(b64CompressedData, 'base64'); var decompressedData = []; var decompressor = zlib.createGunzip(); decompressor.write(b64CompressedBuf); decompressor.end(); decompressor.on('data', function(d) { decompressedData.push(d); }); decompressor.on('error', function(e) { console.error('error: ' + e); }); decompressor.on('end', function() { console.log(decompressedData.join('')); }); });