本文整理汇总了TypeScript中jszip.folder函数的典型用法代码示例。如果您正苦于以下问题:TypeScript folder函数的具体用法?TypeScript folder怎么用?TypeScript folder使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了folder函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test("finds root in simple zip", () => {
const zip = new JSZip();
zip.folder("GFX");
zip.folder("MGFX");
zip.folder("SAVEGAME");
expect(findRootInZip(zip)).toEqual(zip);
});
示例2: it
it("works", async () => {
const nar = new JSZip();
nar.folder("ikaga").file("install.txt", install);
nar.folder("ikaga").file("descript.txt", descript);
const narData = await nar.generateAsync({type: "arraybuffer"});
const dir = await NarLoader.loadFromBuffer(narData);
assert(dir.new("descript.txt").isFileSync());
const installInfo = dir.installInfoSync();
assert(installInfo.type === "ghost");
const descriptInfo = dir.descriptInfoByTypeSync("ghost");
assert(descriptInfo.shiori === "shiolink.dll");
});
示例3: downloadProject
export async function downloadProject(project: Project, uri?: string) {
const zipFile: JSZip = new JSZip();
let zipName: string = "wasm-project.zip";
if (uri !== undefined) {
zipName = `wasm-project-${uri}.zip`;
}
const queue: Array<{filePrefix: string; file: File}> = [];
project.mapEachFile((f: File) => queue.push({filePrefix: "", file: f}));
while (queue.length > 0) {
const {filePrefix, file} = queue.shift();
const fileName = filePrefix + file.name;
if (file instanceof Directory) {
file.mapEachFile(f => queue.push({filePrefix: fileName + "/", file: f}));
zipFile.folder(fileName);
continue;
}
zipFile.file(fileName, file.data);
}
await zipFile.generateAsync({type: "blob", mimeType: "application/zip"}).then((blob: Blob) => {
// Creating <a> to programmatically click for downloading zip via blob's URL
const link = document.createElement("a");
link.download = zipName;
link.href = URL.createObjectURL(blob);
// A fix for making link clickable in Firefox
// Explicity adding link to DOM for Firefox
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
}
示例4:
EXPORTED_FPS.forEach(fps => {
const numSteps = Math.ceil(anim.duration / 1000 * fps);
const svgs = SpriteSerializer.createSvgFrames(vl, anim, numSteps);
const length = (numSteps - 1).toString().length;
const fpsFolder = zip.folder(`${fps}fps`);
svgs.forEach((s, i) => {
fpsFolder.file(`frame${_.padStart(i.toString(), length, '0')}.svg`, s);
});
});
示例5: findRootInZip
export function findRootInZip(zip: JSZip): JSZip {
const gfxFolder = zip.filter(relativePath =>
("/" + relativePath).endsWith("/GFX/")
);
if (gfxFolder.length === 1) {
return zip.folder(gfxFolder[0].name.replace("GFX/", ""));
}
throw new Error("Your ZIP file does not have the expected structure.");
}
示例6: asyncForEach
await asyncForEach(EXPORTED_FPS, async (fps) => {
const numSteps = Math.ceil(anim.duration / 1000 * fps);
const svgSprite = await SpriteSerializer.createSvgSprite(vl, anim, numSteps);
const cssSprite = SpriteSerializer.createCss(vl.width, vl.height, anim.duration, numSteps);
const fileName = `sprite_${fps}fps`;
const htmlSprite = SpriteSerializer.createHtml(`${fileName}.svg`, `${fileName}.css`);
const spriteFolder = zip.folder(`${fps}fps`);
spriteFolder.file(`${fileName}.html`, htmlSprite);
spriteFolder.file(`${fileName}.css`, cssSprite);
spriteFolder.file(`${fileName}.svg`, svgSprite);
});
示例7: create
export function create(callback: (blob: Blob) => any) {
let zip = new JSZip();
let mainfsfolder = zip.folder("mainfs");
let mainfsDirCount = mainfs.getDirectoryCount();
for (let d = 0; d < mainfsDirCount; d++) {
let dirFolder = mainfsfolder.folder(d.toString());
let dirFileCount = mainfs.getFileCount(d);
for (let f = 0; f < dirFileCount; f++) {
let file = mainfs.get(d, f);
let name = f.toString();
if (FORM.isForm(file))
name += ".form";
else if (MTNX.isMtnx(file))
name += ".mtnx";
dirFolder.file(name, file);
}
}
zip.generateAsync({type: "blob"}).then(callback);
}