{"size": 751, "ext": "js", "max_stars_repo_path": "lib/AddOnHandler.js", "max_stars_repo_name": "Instathings/gate", "max_stars_repo_stars_event_min_datetime": "2020-02-02T14:33:06.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-08T10:49:30.000Z", "max_issues_repo_path": "lib/AddOnHandler.js", "max_issues_repo_name": "Instathings/gate", "max_issues_repo_issues_event_min_datetime": "2020-04-08T14:18:08.000Z", "max_issues_repo_issues_event_max_datetime": "2020-04-08T14:18:08.000Z", "max_forks_repo_path": "lib/AddOnHandler.js", "max_forks_repo_name": "Instathings/gate", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 6, "max_issues_count": 1, "max_forks_count": null, "avg_line_length": 21.4571428571, "max_line_length": 72, "alphanum_fraction": 0.6351531292}
const debug = require('debug');
const _ = require('lodash');

const log = debug('gate:log');
log.log = console.log.bind(console); // don't forget to bind to console!

class AddOnHandler {
  constructor() {
    this.instances = [];
  }

  static getInstance() {
    if (this.instance === undefined) {
      this.instance = new AddOnHandler();
    }
    return this.instance;
  }

  add(addOnInstance) {
    log(`AddOnHandler added instance ${addOnInstance.id}`);
    this.instances.push(addOnInstance);
  }

  get(id) {
    return this.instances.find((element) => element.id === id);
  }

  remove(id) {
    log(`AddOnHandler removed instance ${id}`);
    _.remove(this.instances, (element) => element.id === id);
  }
}

module.exports = AddOnHandler;
