Skip to content

Commit 9a9ff27

Browse files
Steven-John Langejanl
authored andcommitted
chore: remove IE polyfill for ArrayBuffer.slice
1 parent 8739f80 commit 9a9ff27

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1-
function cloneArrayBuffer(buff) {
2-
if (typeof buff.slice === 'function') {
3-
return buff.slice(0);
4-
}
5-
// IE10-11 slice() polyfill
6-
var target = new ArrayBuffer(buff.byteLength);
7-
var targetArray = new Uint8Array(target);
8-
var sourceArray = new Uint8Array(buff);
9-
targetArray.set(sourceArray);
10-
return target;
11-
}
12-
1+
/**
2+
* @template {ArrayBuffer | Blob} T
3+
* @param {T} object
4+
* @returns {T}
5+
*/
136
function cloneBinaryObject(object) {
14-
if (object instanceof ArrayBuffer) {
15-
return cloneArrayBuffer(object);
16-
}
17-
// Blob
18-
return object.slice(0, object.size, object.type);
7+
return object instanceof ArrayBuffer
8+
? object.slice(0)
9+
: object.slice(0, object.size, object.type);
1910
}
2011

2112
export default cloneBinaryObject;

0 commit comments

Comments
 (0)