Skip to content

Commit 43a7a5e

Browse files
committed
switch to cfb for zip operations
1 parent f78c866 commit 43a7a5e

39 files changed

+12350
-27388
lines changed

.flowconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
.*/xlsx.mini.js
1818
.*/xlsx.mini.flow.js
1919
.*/xlsxworker.js
20-
.*/jszip.js
2120
.*/tests/.*
2221
.*/demos/.*
2322

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
SHELL=/bin/bash
22
LIB=xlsx
33
FMT=xlsx xlsm xlsb ods xls xml misc full
4-
REQS=jszip.js
4+
REQS=
55
ADDONS=dist/cpexcel.js
66
AUXTARGETS=
77
CMDS=bin/xlsx.njs

bits/05_buf.js

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ if(typeof Buffer !== 'undefined') {
1414

1515
function new_raw_buf(len/*:number*/) {
1616
/* jshint -W056 */
17-
return has_buf ? Buffer.alloc(len) : new Array(len);
17+
return has_buf ? Buffer.alloc(len) : typeof Uint8Array != "undefined" ? new Uint8Array(len) : new Array(len);
1818
/* jshint +W056 */
1919
}
2020

2121
function new_unsafe_buf(len/*:number*/) {
2222
/* jshint -W056 */
23-
return has_buf ? Buffer.allocUnsafe(len) : new Array(len);
23+
return has_buf ? Buffer.allocUnsafe(len) : typeof Uint8Array != "undefined" ? new Uint8Array(len) : new Array(len);
2424
/* jshint +W056 */
2525
}
2626

@@ -55,6 +55,52 @@ function ab2a(data/*:ArrayBuffer|Uint8Array*/)/*:Array<number>*/ {
5555
return o;
5656
}
5757

58-
var bconcat = function(bufs) { return [].concat.apply([], bufs); };
58+
function utf8decode(content/*:string*/) {
59+
var out = [], widx = 0;
60+
var o = new_raw_buf(content.length + 255);
61+
for(var ridx = 0; ridx < content.length; ++ridx) {
62+
var c = content.charCodeAt(ridx);
63+
if(c < 0x80) o[widx++] = c;
64+
else if(c < 0x800) {
65+
o[widx++] = (192|((c>>6)&31));
66+
o[widx++] = (128|(c&63));
67+
} else if(c >= 0xD800 && c < 0xE000) {
68+
c = (c&1023)+64;
69+
var d = str.charCodeAt(++ridx)&1023;
70+
o[widx++] = (240|((c>>8)&7));
71+
o[widx++] = (128|((c>>2)&63));
72+
o[widx++] = (128|((d>>6)&15)|((c&3)<<4));
73+
o[widx++] = (128|(d&63));
74+
} else {
75+
o[widx++] = (224|((c>>12)&15));
76+
o[widx++] = (128|((c>>6)&63));
77+
o[widx++] = (128|(c&63));
78+
}
79+
if(widx > 65530) {
80+
out.push(o.slice(0, widx));
81+
widx = 0;
82+
o = new_raw_buf(65535);
83+
}
84+
}
85+
out.push(o.slice(0, widx));
86+
return bconcat(out);
87+
}
88+
89+
var bconcat = function(bufs) {
90+
if(typeof Uint8Array !== "undefined") {
91+
var i = 0, maxlen = 0;
92+
for(i = 0; i < bufs.length; ++i) maxlen += bufs[i].length;
93+
var o = new Uint8Array(maxlen);
94+
var len = 0;
95+
for(i = 0, maxlen = 0; i < bufs.length; maxlen += len, ++i) {
96+
len = bufs[i].length;
97+
if(bufs[i] instanceof Uint8Array) o.set(bufs[i], maxlen);
98+
else if(typeof bufs[i] == "string") { throw "wtf"; }
99+
else o.set(new Uint8Array(bufs[i]), maxlen);
100+
}
101+
return o;
102+
}
103+
return [].concat.apply([], bufs.map(function(buf) { return Array.isArray(buf) ? buf : [].slice.call(buf); }));
104+
};
59105

60106
var chr0 = /\u0000/g, chr1 = /[\u0001-\u0006]/g;

0 commit comments

Comments
 (0)