Skip to content

Commit

Permalink
Merge pull request #236 from ypetya/master
Browse files Browse the repository at this point in the history
#235 Lazy reference zip.js
  • Loading branch information
micmro authored Sep 3, 2018
2 parents 23ca585 + 7713260 commit 95aa781
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/ts/file-reader.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Har } from "har-format";

declare const zip: any;

// use zip
zip.useWebWorkers = false;
const getConfiguredZipJs = () => {
const zip = window["zip"] || {};
zip.useWebWorkers = false;
return zip;
};

/** handle client side file upload */
export function readFile(file: File,
Expand All @@ -25,6 +27,8 @@ export function readFile(file: File,

/** start reading the file */
const extension = (fileName.match(/\.[0-9a-z]+$/i) || [])[0];
const zip = getConfiguredZipJs();

if ([".zhar", ".zip"].indexOf(extension) !== -1) {
/** zhar */
zip.createReader(new zip.BlobReader(file), (zipReader) => {
Expand Down

0 comments on commit 95aa781

Please sign in to comment.