{"size": 642, "ext": "js", "max_stars_repo_path": "server/libs/teams.js", "max_stars_repo_name": "skarab42/skarabot", "max_stars_repo_stars_event_min_datetime": "2020-11-09T10:13:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-25T22:52:17.000Z", "max_issues_repo_path": "server/libs/teams.js", "max_issues_repo_name": "skarab42/skarabot", "max_issues_repo_issues_event_min_datetime": "2020-11-10T15:24:19.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-13T21:02:53.000Z", "max_forks_repo_path": "server/libs/teams.js", "max_forks_repo_name": "skarab42/skarabot", "max_forks_repo_forks_event_min_datetime": "2020-11-20T15:01:57.000Z", "max_forks_repo_forks_event_max_datetime": "2020-12-19T15:52:54.000Z"}
{"max_stars_count": 21, "max_issues_count": 7, "max_forks_count": 2, "avg_line_length": 15.2857142857, "max_line_length": 53, "alphanum_fraction": 0.6168224299}
const teamsStore = require("../store/teams");

function create(team) {
  return {
    name: null,
    icon: null,
    ...team,
  };
}

function set(name, team) {
  teamsStore.set(`list.${name}`, team);
  return team;
}

function get(name, defaultteam = null) {
  return teamsStore.get(`list.${name}`, defaultteam);
}

function update(newteam) {
  const team = { ...get(newteam.name), ...newteam };
  set(team.name, team);
  return team;
}

function del(name) {
  teamsStore.delete(`list.${name}`);
}

function getAll() {
  return teamsStore.get("list", {});
}

module.exports = {
  create,
  set,
  get,
  getAll,
  update,
  delete: del,
};
