当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript jszip.folder函数代码示例

本文整理汇总了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);
});
开发者ID:ewaldbenes,项目名称:Anno2018-js,代码行数:8,代码来源:util.test.ts

示例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");
 });
开发者ID:Ikagaka,项目名称:NarLoader,代码行数:12,代码来源:basic.ts

示例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);
  });
}
开发者ID:hleal18,项目名称:WebAssemblyStudio,代码行数:30,代码来源:download.ts

示例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);
   });
 });
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:9,代码来源:fileexport.service.ts

示例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.");
}
开发者ID:ewaldbenes,项目名称:Anno2018-js,代码行数:9,代码来源:util.ts

示例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);
 });
开发者ID:arpitsaan,项目名称:ShapeShifter,代码行数:11,代码来源:fileexport.service.ts

示例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);
}
开发者ID:PartyPlanner64,项目名称:PartyPlanner64,代码行数:21,代码来源:dump.ts


注:本文中的jszip.folder函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。