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


TypeScript unzip.Parse函數代碼示例

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


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

示例1:

	return new Promise<void>((resolve, reject) => {
		readStream
			.pipe(unzip.Parse())
			.pipe(writeStream)
			.on('close', resolve)
			.on('error', reject);
	});
開發者ID:Tomdye,項目名稱:dojo-cli,代碼行數:7,代碼來源:gitModule.ts

示例2:

 response.on('end', () => {
     Debug.info('PHPStubs Download Complete');
     Debug.info(`Unzipping to ${this.getStubsDir()}`);
     fs.createReadStream(tmp)
         .pipe(unzip.Parse())
         .pipe(fstream.Writer(this.getStubsDir()));
     window.showInformationMessage('PHP Library Stubs downloaded and installed. You may need to re-index the workspace for them to work correctly.', 'Rebuild Now').then(item => {
         this.rebuildProject();
     });
 });
開發者ID:HvyIndustries,項目名稱:crane,代碼行數:10,代碼來源:Cranefs.ts

示例3: Promise

		return new Promise(resolve => {
			createReadStream(file.getPath(requestState))
				.pipe(unzip.Parse())
				.on('entry', entry => {
					if (entry.type === 'File') {
						archive.append(entry, {
							name: this.getArchivedFilename(entry.path, file.name),
						});
					} else {
						entry.autodrain();
					}
				})
				.on('error', (err: Error) => logger.info(requestState, 'Error extracting from zip: %s', err.message))
				.on('close', resolve);
		});
開發者ID:freezy,項目名稱:node-vpdb,代碼行數:15,代碼來源:release.storage.ts

示例4: Error

  }, (res) => {
    if (res.statusCode !== 200) {
      console.error("Couldn't download the release:");
      const err = new Error(`Unexpected status code: ${res.statusCode}`);
      console.error(err.stack);
      process.exit(1);
    }

    let rootFolderName: string;
    res.pipe(unzip.Parse())
      .on("entry", (entry: any) => {
        if (rootFolderName == null) {
          rootFolderName = entry.path;
          return;
        }

        const entryPath = `${downloadPath}/${entry.path.replace(rootFolderName, "")}`;
        if (entry.type === "Directory") mkdirp.sync(entryPath);
        else entry.pipe(fs.createWriteStream(entryPath));
      })
      .on("close", () => { callback(); });
  });
開發者ID:alphafork,項目名稱:Game-Engine-superpowers-core,代碼行數:22,代碼來源:index.ts

示例5:

import * as unzip from 'unzip';
import * as fs from 'fs';

fs.createReadStream('path/to/archive.zip')
    .pipe(unzip.Extract({ path: 'output/path' }));

fs.createReadStream('path/to/archive.zip')
    .pipe(unzip.Parse())
    .on('entry', (entry: unzip.Entry) => {
        const fileName = entry.path;
        const type = entry.type; // 'Directory' or 'File'
        const size = entry.size;
        if (fileName === "this IS the file I'm looking for") {
            entry.pipe(fs.createWriteStream('output/path'));
        } else {
            entry.autodrain();
        }
    });
開發者ID:AbraaoAlves,項目名稱:DefinitelyTyped,代碼行數:18,代碼來源:unzip-tests.ts


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