diff options
Diffstat (limited to 'browser/unzip.js')
| -rw-r--r-- | browser/unzip.js | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/browser/unzip.js b/browser/unzip.js index 2395fb3..e7ae8b6 100644 --- a/browser/unzip.js +++ b/browser/unzip.js @@ -1,34 +1,12 @@ -var JSZip = require("jszip"); - var promises = require("../lib/promises"); +var zipfile = require("../lib/zipfile"); exports.openZip = openZip; function openZip(options) { if (options.arrayBuffer) { - return openArrayBuffer(options.arrayBuffer); + return zipfile.openArrayBuffer(options.arrayBuffer); } else { return promises.reject(new Error("Could not find file in options")); } } - -function openArrayBuffer(arrayBuffer) { - var zipFile = new JSZip(arrayBuffer); - function exists(name) { - return zipFile.file(name) !== null; - } - - function read(name, encoding) { - var array = zipFile.file(name).asUint8Array(); - var buffer = new Buffer(array); - if (encoding) { - return promises.when(buffer.toString(encoding)); - } else { - return promises.when(buffer); - } - } - return { - exists: exists, - read: read - }; -} |
