From 0c11e5675f9a0d4e263afed413aa656c20734f77 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Wed, 7 May 2014 10:41:44 +0100 Subject: Use jszip on server-side as well as browser-side --- browser/unzip.js | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) (limited to 'browser/unzip.js') 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 - }; -} -- cgit v1.2.3