function parse(
  str,
  sep = "&",
  eq = "=",
  { decodeURIComponent = unescape, maxKeys = 1000 } = {},
) {
  const entries = str.split(sep).map((entry) =>
    entry.split(eq).map(decodeURIComponent)
  );
  const final = {};
  let i = 0;
  while (true) {
    if (Object.keys(final).length === maxKeys && !!maxKeys || !entries[i]) {
      break;
    }
    const [key, val] = entries[i];
    if (final[key]) {
      if (Array.isArray(final[key])) {
        final[key].push(val);
      } else {
        final[key] = [
          final[key],
          val,
        ];
      }
    } else {
      final[key] = val;
    }
    i++;
  }
  return final;
}
/**
 * Parses a URL query string into a collection of key and value pairs.
 * @param str The URL query string to parse
 * @param sep The substring used to delimit key and value pairs in the query string. Default: '&'.
 * @param eq The substring used to delimit keys and values in the query string. Default: '='.
 * @param options The parse options
 */
Parses a URL query string into a collection of key and value pairs.
@param str The URL query string to parse
@param sep The substring used to delimit key and value pairs in the query string.
Parses a URL query string into a collection of key and value pairs . @param str The URL query string to parse @param sep The substring used to delimit key and value pairs in the query string .
function parse(
  str,
  sep = "&",
  eq = "=",
  { decodeURIComponent = unescape, maxKeys = 1000 } = {},
) {
  const entries = str.split(sep).map((entry) =>
    entry.split(eq).map(decodeURIComponent)
  );
  const final = {};
  let i = 0;
  while (true) {
    if (Object.keys(final).length === maxKeys && !!maxKeys || !entries[i]) {
      break;
    }
    const [key, val] = entries[i];
    if (final[key]) {
      if (Array.isArray(final[key])) {
        final[key].push(val);
      } else {
        final[key] = [
          final[key],
          val,
        ];
      }
    } else {
      final[key] = val;
    }
    i++;
  }
  return final;
}
function parse ( str , sep = "&" , eq = "=" , { decodeURIComponent = unescape , maxKeys = 1000 } = { } , ) { const entries = str . split ( sep ) . map ( ( entry ) => entry . split ( eq ) . map ( decodeURIComponent ) ) ; const final = { } ; let i = 0 ; while ( true ) { if ( Object . keys ( final ) . length === maxKeys && ! ! maxKeys || ! entries [ i ] ) { break ; } const [ key , val ] = entries [ i ] ; if ( final [ key ] ) { if ( Array . isArray ( final [ key ] ) ) { final [ key ] . push ( val ) ; } else { final [ key ] = [ final [ key ] , val , ] ; } } else { final [ key ] = val ; } i ++ ; } return final ; }
Parses a URL query string into a collection of key and value pairs.
Parses a URL query string into a collection of key and value pairs .