{"size": 758, "ext": "js", "max_stars_repo_path": "src/helper/loading-helper.js", "max_stars_repo_name": "IBM/SARS-CoV-2-Variant-Browser", "max_stars_repo_stars_event_min_datetime": "2020-12-15T02:07:18.000Z", "max_stars_repo_stars_event_max_datetime": "2021-08-20T00:44:06.000Z", "max_issues_repo_path": "src/helper/loading-helper.js", "max_issues_repo_name": "IBM/SARS-CoV-2-Variant-Browser", "max_issues_repo_issues_event_min_datetime": "2021-12-09T02:40:04.000Z", "max_issues_repo_issues_event_max_datetime": "2021-12-09T02:40:04.000Z", "max_forks_repo_path": "src/helper/loading-helper.js", "max_forks_repo_name": "IBM/SARS-CoV-2-Variant-Browser", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 4, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 17.2272727273, "max_line_length": 59, "alphanum_fraction": 0.610817942}
const showLoader = (flag) => {
  const loader = document.getElementById('loading');
  if (loader) {
    loader.style.display = flag === true ? 'flex' : 'none';
  }
};

let loadCount = 0;

const startLoading = () => {
  if (loadCount <= 0) {
    loadCount = 0;
    showLoader(true);
  }
  loadCount++;
};

const finishLoading = () => {
  loadCount--;
  if (loadCount <= 0) {
    loadCount = 0;
    showLoader(false);
  }
};

const startAndFinishLoadingWith = (loadFunc) => {
  startLoading();
  finishLoadingWith(loadFunc);
};

const finishLoadingWith = (loadFunc) => {
  setTimeout(() => {
    loadFunc();
    setTimeout(() => finishLoading(), 1);
  }, 200);
};

export {
  startLoading,
  finishLoading,
  startAndFinishLoadingWith,
  finishLoadingWith,
};
