本文整理汇总了TypeScript中zlib.gunzipSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript gunzipSync函数的具体用法?TypeScript gunzipSync怎么用?TypeScript gunzipSync使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gunzipSync函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
var r = fs.createReadStream('file.txt');
var z = zlib.createGzip();
var w = fs.createWriteStream('file.txt.gz');
r.pipe(z).pipe(w);
r.close();
}
////////////////////////////////////////////////////
/// zlib tests : http://nodejs.org/api/zlib.html ///
////////////////////////////////////////////////////
namespace zlib_tests {
{
const gzipped = zlib.gzipSync('test');
const unzipped = zlib.gunzipSync(gzipped.toString());
}
{
const deflate = zlib.deflateSync('test');
const inflate = zlib.inflateSync(deflate.toString());
}
}
////////////////////////////////////////////////////////
/// Crypto tests : http://nodejs.org/api/crypto.html ///
////////////////////////////////////////////////////////
namespace crypto_tests {
{
var hmacResult: string = crypto.createHmac('md5', 'hello').update('world').digest('hex');
示例2: read
/**
* Read the contents from the compressed file.
*/
function read(filename: string) {
let content = fs.readFileSync(filename);
let jsonString = zlib.gunzipSync(content);
return JSON.parse(jsonString);
}
示例3: uncompress
public static uncompress(buffer: Buffer): Buffer {
return zlib.gunzipSync(buffer);
}
示例4: inflateBody
async function inflateBody(response: Response): Promise<string> {
const buffer = await response.arrayBuffer()
return zlib.gunzipSync(new DataView(buffer)).toString()
}
示例5: inflateRawSync
);
const inflatedRaw: Buffer = inflateRawSync(deflateRawSync(compressMe));
const inflatedRawString: Buffer = inflateRawSync(deflateRawSync(compressMeString));
// gzip
gzip(compressMe, (err: Error | null, result: Buffer) => gunzip(result, (err: Error | null, result: Buffer) => result));
gzip(
compressMe,
{ finishFlush: constants.Z_SYNC_FLUSH },
(err: Error | null, result: Buffer) => gunzip(
result, { finishFlush: constants.Z_SYNC_FLUSH },
(err: Error | null, result: Buffer) => result
)
);
const gunzipped: Buffer = gunzipSync(gzipSync(compressMe));
unzip(compressMe, (err: Error | null, result: Buffer) => result);
unzip(compressMe, { finishFlush: constants.Z_SYNC_FLUSH }, (err: Error | null, result: Buffer) => result);
const unzipped: Buffer = unzipSync(compressMe);
const bOpts: BrotliOptions = {
chunkSize: 123,
flush: 123123,
params: {
[constants.BROTLI_PARAM_LARGE_WINDOW]: true,
[constants.BROTLI_PARAM_NPOSTFIX]: 123,
},
finishFlush: 123123,
};
示例6: require
var TestModule = require("./TestModule");
var zlib = require('zlib');
var pgp = require('pg-promise')();
var cn = {
host: 'localhost',
port: 5432,
database: 'Test',
user: 'postgres',
password: 'postgres'
};
var db = pgp(cn);
var qrm = pgp.queryResult;
const dataPath = "./Data/data.txt.gz";
var buffer = fs.readFileSync(dataPath);
TestModule.init(zlib.gunzipSync(buffer));
var startCase = 1;
var endCase = 5000;
var i = startCase;
var totalSuccess = 0;
var totalFail = 0;
var minSuccess = 100;
var maxSuccess = 0;
function testRun() {
db.query("SELECT * FROM \"Cases\" WHERE \"CaseSetId\" = ${caseSetId}", {
caseSetId: i
}, qrm.many).then((tests) => {
i++;
if(i <= endCase) {