8000 Added IE10 hack for ArrayBuffer slice · TeskeVirtualSystem/struct.js@0181640 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0181640

Browse files
committed
Added IE10 hack for ArrayBuffer slice
1 parent 1b3b199 commit 0181640

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/struct.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,21 @@ Struct.String2ArrayBuffer = function(str) {
5454
return buf;
5555
};
5656

57+
/* IE10 Hack for ArrayBuffer slice */
58+
if(!ArrayBuffer.prototype.slice) {
59+
ArrayBuffer.prototype.slice = function(start,end) {
60+
var arr = ArrayBuffer(end-start);
61+
var uchar = new Uint8Array(this);
62+
var uchar2 = new Uint8Array(arr);
63+
var c = 0;
64+
for(var i=start;i<end;i++) {
65+
uchar2[c] = uchar[i];
66+
c++;
67+
}
68+
return arr;
69+
};
70+
};
71+
5772
/* Main unpack function */
5873
Struct.unpack = function(mode, string) {
5974
var retval = [],

0 commit comments

Comments
 (0)
0