Skip to content

Instantly share code, notes, and snippets.

@preco21
Forked from 72lions/concat.array.buffers.js
Last active September 7, 2015 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save preco21/1c5297d9a6e2e0a2979b to your computer and use it in GitHub Desktop.
Save preco21/1c5297d9a6e2e0a2979b to your computer and use it in GitHub Desktop.
Concatenates two ArrayBuffers
/**
* Creates a new Uint8Array based on two different ArrayBuffers
*
* @private
* @param {ArrayBuffers} buffer1 The first buffer.
* @param {ArrayBuffers} buffer2 The second buffer.
* @return {ArrayBuffers} The new ArrayBuffer created out of the two.
*/
var _appendBuffer = function(buffer1, buffer2) {
var tmp = new Uint8Array(buffer1.byteLength + buffer2.byteLength);
tmp.set(new Uint8Array(buffer1), 0);
tmp.set(new Uint8Array(buffer2), buffer1.byteLength);
return tmp.buffer;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment