{"size": 689, "ext": "js", "max_stars_repo_path": "site/assets/js/worker.js", "max_stars_repo_name": "MakeNowJust-Labo/recheck", "max_stars_repo_stars_event_min_datetime": "2021-02-08T13:34:05.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-27T23:12:07.000Z", "max_issues_repo_path": "site/assets/js/worker.js", "max_issues_repo_name": "MakeNowJust-Labo/redos", "max_issues_repo_issues_event_min_datetime": "2021-04-28T21:12:46.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-02T20:21:58.000Z", "max_forks_repo_path": "site/assets/js/worker.js", "max_forks_repo_name": "MakeNowJust-Labo/recheck", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 42, "max_issues_count": 192, "max_forks_count": null, "avg_line_length": 26.5, "max_line_length": 93, "alphanum_fraction": 0.6313497823}
import { check } from './lib/recheck';

const TIMEOUT = 30000;

const extract = input => {
  if (!input.startsWith("/")) return null;
  const lastSlashPos = input.lastIndexOf('/');
  if (lastSlashPos === 0) return null;
  return {
    source: input.slice(1, lastSlashPos),
    flags: input.slice(lastSlashPos + 1),
  };
};

onmessage = e => {
  const { checker, input } = e.data;
  const extracted = extract(input);
  if (extracted === null) {
    postMessage({ status: 'unknown', error: { kind: 'invalid', message: 'invalid input' } });
    return;
  }
  const { source, flags } = extracted;
  const result = check(source, flags, { timeout: TIMEOUT, checker });
  postMessage(result);
};
