{"size": 896, "ext": "js", "max_stars_repo_path": "frontend/src/utils/parseRequestParams.js", "max_stars_repo_name": "MMotionMan/django-edw", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "frontend/src/utils/parseRequestParams.js", "max_issues_repo_name": "MMotionMan/django-edw", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "frontend/src/utils/parseRequestParams.js", "max_forks_repo_name": "MMotionMan/django-edw", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 26.3529411765, "max_line_length": 66, "alphanum_fraction": 0.5814732143}
function parseIntList(param, name) {
  let ret = [],
    arr = param.replace(`${name}=`, '').split(',');
  for (const value of arr) {
    const num = parseInt(value, 10);
    if (!isNaN(num))
      ret.push(num);
  }
  return ret;
}

export default function parseRequestParams(request_params) {
  let term_ids = [],
    subj_ids = [],
    limit = -1,
    options_arr = [];

  for (const param of request_params) {
    if (param.startsWith('terms=')) {
      term_ids = parseIntList(param, 'terms');
    } else if (param.startsWith('subj=')) {
      subj_ids = parseIntList(param, 'subj');
    } else if (param.startsWith('limit=')) {
      limit = parseIntList(param, 'limit');
    } else {
      if (param.includes('['))
        options_arr.push(param.replace('[', '').replace(']', ''));
      else
        options_arr.push(param);
    }
  }
  return {term_ids, subj_ids, limit, options_arr};
}
