Skip to content

Instantly share code, notes, and snippets.

@also
Created April 10, 2011 05:47
Show Gist options
  • Save also/912082 to your computer and use it in GitHub Desktop.
Save also/912082 to your computer and use it in GitHub Desktop.
readAsArrayBuffer polyfill for Firefox 4
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