本文整理汇总了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;未经允许,请勿转载。 |
请发表评论