var a = [
{a:1},
{b:2}
]
const zlib = require('zlib');
const fs = require('fs');
/**
* Read the gz compresed file
* @param filename (string) full path to file
* @return (Promise<Buffer>)
*/
function readGZipFile(filename) {
return new Promise((resolve, reject) => {
fs.readFile(filename, (err, buf) => {
if(err) {
reject(err);
return;
}
zlib.gunzip(buf, (err, buf) => {
if(err) {
reject(err);
return;
}
resolve(buf);
});
});
});
}
//Использование
const path = require('path');
readGZipFile(path.resolve(__dirname, 'lib.txt.gz')).then(buf => JSON.parse(buf.toString())).then(data => {
//Ваш код для работы с data
});