{"size": 616, "ext": "js", "max_stars_repo_path": "src/common/index.js", "max_stars_repo_name": "ma-lihui/electron-demo", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/common/index.js", "max_issues_repo_name": "ma-lihui/electron-demo", "max_issues_repo_issues_event_min_datetime": "2020-09-03T23:08:25.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-25T18:20:35.000Z", "max_forks_repo_path": "src/common/index.js", "max_forks_repo_name": "ma-lihui/markdown-editor", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 4, "max_forks_count": null, "avg_line_length": 19.25, "max_line_length": 43, "alphanum_fraction": 0.6217532468}

export function setItem(key,value){
  if(typeof value === 'object'){
    value = JSON.stringify(value);
    value = 'obj-'+ value;
  }else{
    value = 'str-'+ value;
  }
  localStorage.setItem(key, value);
}

export function getItem(key) {
  let value = localStorage.getItem(key);
  if (!value) {
    return;
  }
  if (value.indexOf('obj-') === 0) {
    value = value.slice(4);
    return JSON.parse(value);
  } else if (value.indexOf('str-') === 0) {
    return value.slice(4);
  }
}

export function removeItem(key) {
  localStorage.removeItem(key);
}

export function clearStorage() {
  localStorage.clear();
}
