當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript zlib.gunzipSync函數代碼示例

本文整理匯總了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');
開發者ID:DenisCarriere,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:node-tests.ts

示例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);
}
開發者ID:TheLarkInn,項目名稱:awesome-typescript-loader,代碼行數:8,代碼來源:cache.ts

示例3: uncompress

 public static uncompress(buffer: Buffer): Buffer {
     return zlib.gunzipSync(buffer);
 }
開發者ID:swanest,項目名稱:micromessaging,代碼行數:3,代碼來源:Utils.ts

示例4: inflateBody

async function inflateBody(response: Response): Promise<string> {
  const buffer = await response.arrayBuffer()
  return zlib.gunzipSync(new DataView(buffer)).toString()
}
開發者ID:dianpeng,項目名稱:fly,代碼行數:4,代碼來源:gzip.tests.ts

示例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,
};
開發者ID:CNBoland,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:zlib.ts

示例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) {
開發者ID:Dyas,項目名稱:challenge_word_classifier,代碼行數:31,代碼來源:Main.ts


注:本文中的zlib.gunzipSync函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。