当前位置: 首页>>代码示例>>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;未经允许,请勿转载。