function toArrayBuffer(buf) {
  if (buf.length === buf.buffer.byteLength) {
    return buf.buffer;
  }

  return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.length);
}
Converts a buffer to an `ArrayBuffer`.

@param {Buffer} buf The buffer to convert
@return {ArrayBuffer} Converted buffer
@public