code: function b64encode(str) {
      const buf = Buffer.isBuffer(str) ? str : Buffer.from(str);
      return b64escape(buf.toString('base64'));
  }
docs: Base64 encode and escape buffer or string
  
  @param {buffer|string} str Buffer or string to be encoded
  @returns {string} Escaped base64 encoded string