code: function toUint8Array(buf) {
    if (buf instanceof Uint8Array) {
      return buf;
    } else if (buf instanceof ArrayBuffer) {
      return new Uint8Array(buf);
    } else if (Buffer.isBuffer(buf)) {
      return new Uint8Array(buf);
    } else {
      return buf; // type unknown, trust the user
    }
  }
docs: Converts any buffer to Uint8Array
  @param {Buffer|ArrayBuffer|Uint8Array} buf Input buffer
  @returns {Uint8Array}