index.js
function buf2hex(buffer, options = { prefix: true }) {
  var hex = Array.prototype.map
    .call(new Uint8Array(buffer), x => ('00' + x.toString(16)).slice(-2))
    .join('');

  return options.prefix === true ? `0x${hex}` : hex;
}
function buf2hex(buffer, options = { prefix: true }) {
  var hex = Array.prototype.map
    .call(new Uint8Array(buffer), x => ('00' + x.toString(16)).slice(-2))
    .join('');

  return options.prefix === true ? `0x${hex}` : hex;
}
Reads the information inside a buffer, an returns it as a string.
@param {Buffer} buffer - Converts the data stored in a Buffer to a hex string
@param {Object} options - Options configuration object.
@property {bool} prefix=true - Whether to add the prefix to the string or not
@return {string} Encoded buffer data as a string.