{"size": 1834, "ext": "js", "max_stars_repo_path": "src/util/uri-encoder.js", "max_stars_repo_name": "snags88/wtfetch", "max_stars_repo_stars_event_min_datetime": "2018-04-03T19:08:15.000Z", "max_stars_repo_stars_event_max_datetime": "2018-04-03T19:08:15.000Z", "max_issues_repo_path": "src/util/uri-encoder.js", "max_issues_repo_name": "snags88/wtfetch", "max_issues_repo_issues_event_min_datetime": "2018-04-02T18:33:51.000Z", "max_issues_repo_issues_event_max_datetime": "2018-07-21T03:14:06.000Z", "max_forks_repo_path": "src/util/uri-encoder.js", "max_forks_repo_name": "snags88/wtfetch", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 26.5797101449, "max_line_length": 112, "alphanum_fraction": 0.5267175573}
// this is borrowed from $.param except with no jQuery and a few other modifications.
// https://github.com/jquery/jquery/blob/master/src/serialize.js

export const param = (obj) => {
  let prefix, key, value,
      r20 = /%20/g,
      serialized = [],

      add = (key, value) => {
        value = isFunction(value) ? value() : (value === null ? "" : value);
        if ( value === undefined) {
          serialized[serialized.length] = value;
        } else {
          serialized[serialized.length] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
        }
      };

  if(Array.isArray(obj)) {
    for(key in obj) {
      value = obj[key];
      add(key, value);
    }
  } else {
    for(prefix in obj) {
      buildParams(prefix, obj[prefix], add);
    }
  }

  return serialized.filter(k => k !== undefined)
    .join('&').replace(r20, '+');
};

const type = (obj) => {
  let class2type = {},
      toString = class2type.toString
      ;

  if ( obj == null ) { return obj + ""; }
  // Support: Android < 4.0, iOS < 6 (functionish RegExp)
  return typeof obj === "object" || typeof obj === "function" ?
      class2type[ toString.call(obj) ] || "object" : typeof obj;
};

const isFunction = (obj) => {
  return type(obj) === "function";
};

const buildParams = (prefix, obj, add) => {
    let name, key, value,
        rbracket = /\[\]$/;

    if(Array.isArray(obj)) {
      for(key in obj) {
        value = obj[key]
        if(rbracket.test(prefix)) {
          add(prefix, value);
        } else {
          buildParams(prefix + "[" + (typeof value === "object" && value != null ? key : "") + "]", value, add);
        }
      }
    } else if(type(obj) === 'object') {
      for(name in obj) {
        buildParams(prefix + "[" + name + "]", obj[name], add);
      }
    } else {
      add(prefix, obj);
    }
};
