file gzip
const zlib = require('zlib'); const gzip = zlib.createGzip(); const fs = require('fs'); const inp = fs.createReadStream('input.txt'); const out = fs.createWriteStream('input.txt.gz'); inp.pipe(gzip).pipe(out);
string flate
const input = '.................................'; zlib.deflate(input, (err, buffer) => { if (!err) { console.log(buffer.toString('base64')); } else { // handle error } }); const buffer = Buffer.from('eJzT0yMAAGTvBe8=', 'base64'); zlib.unzip(buffer, (err, buffer) => { if (!err) { console.log(buffer.toString()); } else { // handle error } });
반응형
'lang > node' 카테고리의 다른 글
2진수 채우기 zerofill (0) | 2018.01.12 |
---|---|
node.js Buffer (0) | 2018.01.11 |
Pm2 log dateformat (0) | 2017.06.16 |
pm2 JSON(설정)으로 실행 (0) | 2017.03.13 |
pm2 1.1.3 to 2.1.5 upgrade (0) | 2016.11.24 |