Created
February 13, 2017 10:53
-
-
Save beckettkev/8103be22a8fec23eefc08d402d637667 to your computer and use it in GitHub Desktop.
Getting started with Uploading Large Files...
This file contains hidden or 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
import utils from './utils'; | |
if (!ArrayBuffer.prototype.slice) { | |
ArrayBuffer.prototype.slice = function (begin, end) { | |
let len = this.byteLength; | |
begin = (begin|0) || 0; | |
end = end === (void 0) ? len : (end|0); | |
// Handle negative values. | |
if (begin < 0) begin = Math.max(begin + len, 0); | |
if (end < 0) end = Math.max(end + len, 0); | |
if (len === 0 || begin >= len || begin >= end) { | |
return new ArrayBuffer(0); | |
} | |
let length = Math.min(len - begin, end - begin); | |
let target = new ArrayBuffer(length); | |
let targetArray = new Uint8Array(target); | |
targetArray.set(new Uint8Array(this, begin, length)); | |
return target; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment