diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-01-06 22:10:58 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-01-06 22:10:58 +0000 |
| commit | 06a8f7548e480b3f46e979c52629601b611b5b78 (patch) | |
| tree | 088492793cb6c6b53f75a0e7a3c77c86e95f5d54 /lib/unzip.js | |
| parent | ee556262e602d2903c5b8d92193295a42291f09d (diff) | |
Move zip reading into unzip.js
Diffstat (limited to 'lib/unzip.js')
| -rw-r--r-- | lib/unzip.js | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/unzip.js b/lib/unzip.js index 858a4da..98709e8 100644 --- a/lib/unzip.js +++ b/lib/unzip.js @@ -1,13 +1,24 @@ -exports.unzipUint8Array = unzipUint8Array; -exports.unzipStream = unzipStream; +exports.openZip = openZip; var q = require("q"); +var fs = require("fs"); var unzip = { Parse: require("unzip/lib/parse") }; var Buffers = require("buffers"); var streamBuffers = require("stream-buffers"); +function openZip(options) { + if (options.path) { + return unzipStream(fs.createReadStream(options.path)); + } else if (options.file) { + return options.file; + } else if (options.uint8Array) { + return unzipUint8Array(options.uint8Array); + } else { + return q.reject(new Error("Could not find file in options")); + } +} function unzipUint8Array(array) { var buffer = new Buffer(array); |
