var fs = require('fs');
var zlib = require('zlib');
fs.createReadStream('input.txt')
.pipe(zlib.createGzip())
.pipe(fs.createWriteStream('input.txt.gz'));
console.log('压缩完成');
ls -alh
-rw-r--r-- 1 phieo staff 13B Nov 10 10:24 input.txt
-rw-r--r-- 1 phieo staff 33B Nov 10 10:33 input.txt.gz