xsheetjs/bits/87_read.js
2015-03-05 12:18:36 -05:00

22 lines
629 B
JavaScript

function readSync(data, opts) {
var zip, d = data;
var o = opts||{};
if(!o.type) o.type = (has_buf && Buffer.isBuffer(data)) ? "buffer" : "base64";
switch(o.type) {
case "base64": zip = new jszip(d, { base64:true }); break;
case "binary": zip = new jszip(d, { base64:false }); break;
case "buffer": zip = new jszip(d); break;
case "file": zip=new jszip(d=_fs.readFileSync(data)); break;
default: throw new Error("Unrecognized type " + o.type);
}
return parse_zip(zip, o);
}
function readFileSync(data, opts) {
var o = opts||{}; o.type = 'file'
var wb = readSync(data, o);
wb.FILENAME = data;
return wb;
}