Appending ArrayBuffers

Why not using a Blob ? (I realize it might not have been available at that time).

Just create a Blob with your data, like var blob = new Blob([array1,array2,string,...]) and turn it back into an ArrayBuffer (if needed) using a FileReader (see this).

Check this : What’s the difference between BlobBuilder and the new Blob constructor?
And this : MDN Blob API

EDIT :

I wanted to compare the efficiency of these two methods (Blobs, and the method used in the question) and created a JSPerf : http://jsperf.com/appending-arraybuffers

Seems like using Blobs is slower (In fact, I guess it’s the use of Filereader to read the Blob that takes the most time). So now you know 😉
Maybe it would me more efficient when there are more than 2 ArrayBuffer (like reconstructing a file from its chunks).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)