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


TypeScript yazl.ZipFile類代碼示例

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


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

示例1: createWriteStream

	return new Promise<string>((c, e) => {
		const zip = new yazl.ZipFile();
		files.forEach(f => f.contents ? zip.addBuffer(typeof f.contents === 'string' ? Buffer.from(f.contents, 'utf8') : f.contents, f.path) : zip.addFile(f.localPath, f.path));
		zip.end();

		const zipStream = createWriteStream(zipPath);
		zip.outputStream.pipe(zipStream);

		zip.outputStream.once('error', e);
		zipStream.once('error', e);
		zipStream.once('finish', () => c(zipPath));
	});
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:12,代碼來源:zip.ts

示例2: require

import { ZipFile } from "yazl";
import { Readable } from "stream";
import fs = require('fs');

const zipfile = new ZipFile();
zipfile.addFile("file1.txt", "file1.txt");
// (add only files, not directories)
zipfile.addFile("path/to/file.txt", "path/in/zipfile.txt");
// pipe() can be called any time after the constructor
// $ExpectType Readable
zipfile.outputStream;
zipfile.outputStream.pipe(fs.createWriteStream("output.zip")).on("close", () => {
	console.log("done");
});
// alternate apis for adding files:
zipfile.addReadStream(process.stdin, "stdin.txt", {
	mtime: new Date(),
	mode: parseInt("0100664", 8), // -rw-rw-r--
});
zipfile.addBuffer(new Buffer("hello"), "hello.txt", {
	mtime: new Date(),
	mode: parseInt("0100664", 8), // -rw-rw-r--
});
// call end() after all the files have been added
zipfile.end();
開發者ID:Jeremy-F,項目名稱:DefinitelyTyped,代碼行數:25,代碼來源:yazl-tests.ts

示例3: if

		files.forEach(f => {
			if (f.contents) {
				zip.addBuffer(typeof f.contents === 'string' ? Buffer.from(f.contents, 'utf8') : f.contents, f.path);
			} else if (f.localPath) {
				zip.addFile(f.localPath, f.path);
			}
		});
開發者ID:joelday,項目名稱:vscode,代碼行數:7,代碼來源:zip.ts

示例4:

		files.forEach(f => f.contents ? zip.addBuffer(typeof f.contents === 'string' ? Buffer.from(f.contents, 'utf8') : f.contents, f.path) : zip.addFile(f.localPath, f.path));
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:1,代碼來源:zip.ts


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