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


TypeScript tar-fs.extract函數代碼示例

本文整理匯總了TypeScript中tar-fs.extract函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript extract函數的具體用法?TypeScript extract怎麽用?TypeScript extract使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了extract函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: unTarGz

 private async unTarGz(zipLocation: string, unzipLocation: string): Promise<void> {
     return Promise.resolve(
         fs
             .createReadStream(zipLocation)
             .pipe(zlib.createGunzip())
             .pipe(tar.extract(unzipLocation))
     );
 }
開發者ID:Microsoft,項目名稱:vsts-tasks,代碼行數:8,代碼來源:packagefile.ts

示例2: downloadJDK

  https.get(url, (res) => {
    if (res.statusCode === 302) {
      // Redirected.
      ended = true;
      downloadJDK(res.headers['location'], destPath, cb);
      return;
    }

    // Will be NaN if not given by server.
    let contentLength = parseInt(res.headers['content-length']);
    let progressBytes = 0;
    let startTime = new Date().getTime();

    function printStatus() {
      let percent = "??";
      if (!isNaN(contentLength)) {
        percent = ((progressBytes/contentLength)*100).toFixed(0);
      }
      let lastPrint = new Date().getTime();
      // bytes => kbytes
      let dlSoFar = progressBytes >> 10;
      let rate = dlSoFar / ((lastPrint - startTime) / 1000);
      console.log(`[${percent}%] Received ${dlSoFar} KB [${rate.toFixed(2)} KB/s]`);
    }

    let interval = setInterval(function() {
      printStatus();
    }, 5000);

    function end(err?: Error) {
      if (!ended) {
        ended = true;
        clearInterval(interval);
        cb(err);
      }
    }

    res.pipe(gunzip()).pipe(tarFs.extract(destPath)).on('error', end).on('finish', end);
    res.on('data', (d: Buffer) => {
      progressBytes += d.length;
    });
  }).on('error', (err: Error) => {
開發者ID:plasma-umass,項目名稱:doppio,代碼行數:42,代碼來源:download_jdk.ts

示例3: resolve

 .on('response', response => {
   if (response.statusCode === 200) {
     stream
       .pipe(zlib.createGunzip())
       .pipe(tar.extract(destination, {
         map: header => {
           header.name = header.name.substring(header.name.indexOf('/'));
           return header;
         }
       }))
       .on('finish', () => {
         resolve(destination);
         stream.destroy();
         Logger.info(`Downloaded ${url} successfuly.`);
       });
   } else {
     reject(`Failed to download ${url}. Status code: ${response.statusCode}.`);
     stream.destroy();
   }
 });
開發者ID:angular,項目名稱:material-tools,代碼行數:20,代碼來源:VersionDownloader.ts


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