code: function buffer2ArrayBuffer(buffer) {
    var buf = new ArrayBuffer(buffer.length);
    var bufView = new Uint8Array(buf);
    for (var i = 0; i < buffer.length; i++) {
      bufView[i] = buffer[i];
    }
    return buf;
  }
docs: Convert buffer to ArrayBuffer