Created
April 10, 2011 05:47
readAsArrayBuffer polyfill for Firefox 4
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
if (!FileReader.prototype.readAsArrayBuffer) { | |
FileReader.prototype.readAsArrayBuffer = function readAsArrayBuffer () { | |
this.readAsBinaryString.apply(this, arguments); | |
this.__defineGetter__('resultString', this.__lookupGetter__('result')); | |
this.__defineGetter__('result', function () { | |
var string = this.resultString; | |
var result = new Uint8Array(string.length); | |
for (var i = 0; i < string.length; i++) { | |
result[i] = string.charCodeAt(i); | |
} | |
return result.buffer; | |
}); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment