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


TypeScript jszip.loadAsync函数代码示例

本文整理汇总了TypeScript中jszip.loadAsync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript loadAsync函数的具体用法?TypeScript loadAsync怎么用?TypeScript loadAsync使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了loadAsync函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: uploadAndParse

  private async uploadAndParse(file: File): Promise<boolean> {
    let zip;
    try {
      await this.fs.write("/original.zip", file);
      const zipFileEntry = await this.fs.open("/original.zip");
      zip = await JSZip.loadAsync(zipFileEntry);
    } catch (e) {
      this.logger.error(`Could not upload the ZIP file: ${e.message}`);
      return false;
    }

    try {
      const annoRoot = findRootInZip(zip);
      await this.fs.rmRoot();

      await this.copyIslands(annoRoot);
      await this.copySaves(annoRoot);
      const customMissionPath = await this.parseTranslations(annoRoot);
      await this.copyMissions(annoRoot, customMissionPath);
      await this.decryptCODs(annoRoot);
      await this.parseDATs();
      await this.parseGADs(annoRoot);
      await this.parseBSHs(annoRoot);
      await this.parseZEIs(annoRoot);
      await this.parseMusic(annoRoot);
      await this.parseVideos(annoRoot);
    } catch (e) {
      this.logger.error(e.message);
      return false;
    }

    return true;
  }
开发者ID:ewaldbenes,项目名称:Anno2018-js,代码行数:33,代码来源:upload.ts

示例2: JSZip

 fs.readFile(pathToJar, (err, data) => {
     let zip = new JSZip();
     zip.loadAsync(data).then((new_zip) => {
         new_zip.file(pathToFileInJar).async("string").then((value) => {
             resolve(value);
         })
     })
 })
开发者ID:avli,项目名称:clojureVSCode,代码行数:8,代码来源:jarContentProvider.ts

示例3: retrieveZipContentList

export function retrieveZipContentList(filePath: string) {
    return JSZip.loadAsync(fs.readFileSync(filePath, 'binary'))
    .then((zip) => {
        let fileArray = [];
        Object.keys(zip.files).forEach((_filename) => {
            fileArray.push(_filename);
        });
        return fileArray;
    });
}
开发者ID:GitWhiskey,项目名称:composer,代码行数:10,代码来源:fileUtils.ts

示例4: function

 reader.onload = function(e) {
   const zipBinary = new Uint8Array((e.target as any).result)
   const zip = new JSZip()
   zip.loadAsync(zipBinary)
     .then((loadedZip: JSZip) => {
       Object.keys(loadedZip.files).forEach(fileName => {
         if (getExt(fileName).toLowerCase() === 'nes') {
           loadedZip.files[fileName].async('uint8array')
             .then((rom) => { onNesFileLoaded(rom, fileName) })
             .catch(error => { console.error(error) })
         }
       })
     })
   .catch(error => {
     console.error(error)
   })
 }
开发者ID:ysei,项目名称:nesemu,代码行数:17,代码来源:main.ts

示例5:

        filereader.onload = (event: any) => {
            Zipper.loadAsync(event.target.result).then((data) => {
                console.log("data", data.files);

                for (var item in data.files) {
                    console.log("file", item);
                    if (item == "meta.json") {
                        Zipper.file('meta.json').async('string').then((data) => {
                            var contents = JSON.parse(data);
                            var success = this.JsonService.setData(contents); 
                            console.log(contents);              
                            this.routeHandler(contents);
                        })
                    }
                }

            });
        }
开发者ID:sethdorris,项目名称:3dzip,代码行数:18,代码来源:UploadComponent.ts

示例6: success

        file.async("nodebuffer").then(function success(content) {
            const jszip = new JSZip();
            jszip.loadAsync(content).then((zip) => {
                const files = zip.files;
                files["Linky.txt"].async("string").then((line: string) => {
                    const lines = myLines.map((el) => linePrefix + el);
                    line = line.split(",")[0].replace(/"/g, "");

                    if (lines.indexOf(line) >= 0) {
                        const folder = path.basename(file.name, path.extname(file.name));
                        const destination = path.join(localDataPath, jdfPath, folder);
                        //todo: delete old folders!
                        mkdir(destination).then(() => {
                            const promises: Promise<string>[] = [];
                            for (let key in files) {
                                if (files.hasOwnProperty(key)) {
                                    const f = files[key];
                                    const promise = new Promise((resolve, reject) => {
                                        f["nodeStream"]()
                                            .pipe(fs.createWriteStream(path.join(destination, f.name)))
                                            .on("finish", () => {
                                                resolve(f.name);
                                            })
                                            .on("error", (e) => {
                                                reject(e);
                                            });
                                    });
                                    promises.push(promise);
                                }
                            }

                            Promise.all(promises).then(() => {
                                resolve(file.name);
                            });
                        }).catch((e) => {
                            reject(e);
                        });
                    } else {
                        resolve(null);
                    }
                });
            });
        }, function error(e) {
开发者ID:graycrow,项目名称:node-cisjr,代码行数:43,代码来源:index.ts

示例7: extract

    public async extract(data: Buffer): Promise<IDocumentTemplate> {
        const zipContent = await JSZip.loadAsync(data);

        const documentContent = await zipContent.files["word/document.xml"].async("text");
        const relationshipContent = await zipContent.files["word/_rels/document.xml.rels"].async("text");

        const documentRefs = this.extractDocumentRefs(documentContent);
        const documentRelationships = this.findReferenceFiles(relationshipContent);

        const media = new Media();

        const templateDocument: IDocumentTemplate = {
            headers: await this.createHeaders(zipContent, documentRefs, documentRelationships, media, 0),
            footers: await this.createFooters(zipContent, documentRefs, documentRelationships, media, documentRefs.headers.length),
            currentRelationshipId: documentRefs.footers.length + documentRefs.headers.length,
            styles: await zipContent.files["word/styles.xml"].async("text"),
            titlePageIsDefined: this.checkIfTitlePageIsDefined(documentContent),
            media: media,
        };

        return templateDocument;
    }
开发者ID:dolanmiu,项目名称:docx,代码行数:22,代码来源:import-dotx.ts

示例8: load

export function load(buffer: ArrayBuffer) {
  let zip = new JSZip();
  zip.loadAsync(buffer).then((zip: any) => {
    let mainfs = zip.folder("mainfs");
    mainfs.forEach((relativePath: string, file: any) => {
      let dirFileRegex = /(\d+)\/(\d+)/;
      let match = relativePath.match(dirFileRegex);
      if (!match)
        return;
      let d = parseInt(match[1]);
      let f = parseInt(match[2]);
      if (isNaN(d) || isNaN(f))
        return;
      file.async("arraybuffer").then((content: ArrayBuffer) => {
        $$log(`Overwriting MainFS ${d}/${f}`);
        mainfs.write(d, f, content);
      });
    });
  }, (error: any) => {
    $$log(error);
    showMessage(`Something went wrong while loading the zip. ${error}`);
  });
}
开发者ID:PartyPlanner64,项目名称:PartyPlanner64,代码行数:23,代码来源:dump.ts

示例9:

        return this.file.readAsArrayBuffer(sourceDir, sourceName).then((data) => {

            // Now load the file using the JSZip library.
            return zip.loadAsync(data);
        }).then((): any => {
开发者ID:SATS-Seminary,项目名称:moodlemobile2,代码行数:5,代码来源:zip.ts

示例10: JSZip

 .then((buffer: Buffer) => {
   const zip = new JSZip()
   return zip.loadAsync(buffer)
 })
开发者ID:tyfkda,项目名称:nesemu,代码行数:4,代码来源:getmapperno.ts


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