blob: 2c004b7babad0e01e81fd1f212276da3fc77c4f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
var JSZip = require("jszip");
var promises = require("./promises");
exports.openArrayBuffer = openArrayBuffer;
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
};
}
|