Skip to content

Commit

Permalink
fix: iOS 9 doesn't support TypedArray slice, add polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
06wj committed Aug 31, 2020
1 parent 56d1682 commit 7ad428a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,21 @@ if (!Object.values) {
if (typeof Promise === 'undefined') {
window.Promise = pinkiePromise;
}

// iOS 9 doesn't support TypedArray slice
[
Int8Array,
Uint8Array,
Int16Array,
Uint16Array,
Uint32Array,
Float32Array
].forEach((TypedArray) => {
if (!TypedArray.prototype.slice) {
Object.defineProperty(TypedArray.prototype, 'slice', {
value(begin, end) {
return new TypedArray(Array.prototype.slice.call(this, begin, end));
}
});
}
});

0 comments on commit 7ad428a

Please sign in to comment.