title: Javascript combine ArrayBuffer parts
body: <p>I need to combine 2 parts of 2 existing arrayBuffers into a new one.</p>
  
  <p>I am building a parser and the data comes in arraybuffers of random sizes, the data will spill over the end of one, into the beginning of the other. So I need to create a new output buffer and copy in a portion of the end of one buffer and a portion of the beginning of the other. The output will just be an Arraybuffer.</p>
  
  <p>Starting out with this demo, I was going to make Uint8Arrays with some offsets then use set, the problem is certain combinations throw <code>Invalid typed array length</code>. I will not know the length of each array or offsets beforehand.</p>
  
  <pre><code>var buffer1 = new ArrayBuffer(8);
  var buffer2 = new ArrayBuffer(8);
  var buffer3 = new ArrayBuffer(8);
  
  var uint8_1 = new Uint8Array(buffer1);
  var uint8_2 = new Uint8Array(buffer2);
  var uint8_3 = new Uint8Array(buffer3);
  
  uint8_1.fill(1);
  uint8_2.fill(2);
  
  var uint8_1_slice = new Uint8Array(buffer1 , 0 , 3);
  var uint8_2_slice = new Uint8Array(buffer2 , 4, 7);
  </code></pre>
  
  <p>For this demo need to get buffer3 to be 1,1,1,1,2,2,2,2.</p>
  
  <blockquote>
    <p>Cannot Use Slice</p>
  </blockquote>