當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。