-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove IE polyfill for ArrayBuffer.slice
- Loading branch information
Showing
1 changed file
with
8 additions
and
17 deletions.
There are no files selected for viewing
25 changes: 8 additions & 17 deletions
25
packages/node_modules/pouchdb-utils/src/cloneBinaryObject-browser.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,12 @@ | ||
function cloneArrayBuffer(buff) { | ||
if (typeof buff.slice === 'function') { | ||
return buff.slice(0); | ||
} | ||
// IE10-11 slice() polyfill | ||
var target = new ArrayBuffer(buff.byteLength); | ||
var targetArray = new Uint8Array(target); | ||
var sourceArray = new Uint8Array(buff); | ||
targetArray.set(sourceArray); | ||
return target; | ||
} | ||
|
||
/** | ||
* @template {ArrayBuffer | Blob} T | ||
* @param {T} object | ||
* @returns {T} | ||
*/ | ||
function cloneBinaryObject(object) { | ||
if (object instanceof ArrayBuffer) { | ||
return cloneArrayBuffer(object); | ||
} | ||
// Blob | ||
return object.slice(0, object.size, object.type); | ||
return object instanceof ArrayBuffer | ||
? object.slice(0) | ||
: object.slice(0, object.size, object.type); | ||
} | ||
|
||
export default cloneBinaryObject; |