code: function encode(data, parse_url) {
      var str;
      var t = typeof data;
  
      if (t == 'string' || t == 'number') {
          str = '' + data;
          data = new Buffer(str);
      } else if (Buffer.isBuffer(data)) {
          str = data.toString();
      } else if (Array.isArray(data)) {
          data = new Buffer(data);
          str = data.toString();
      } else {
          throw new Error("Bad data");
      }
  
      if (/^[0-9]+$/.test(str)) {
          if (data.length > 7089) {
              throw new Error("Too much data");
          }
          return encode_numeric(str);
      }
  
      if (/^[0-9A-Z \$%\*\+\.\/\:\-]+$/.test(str)) {
          if (data.length > 4296) {
              throw new Error("Too much data");
          }
          return encode_alphanum(str);
      }
  
      if (parse_url && /^https?:/i.test(str)) {
          return encode_url(str);
      }
  
      if (data.length > 2953) {
          throw new Error("Too much data");
      }
      return encode_8bit(data);
  }
docs: {{{1 Choose encode mode and generates struct with data for different version