{"size": 985, "ext": "js", "max_stars_repo_path": "core/Item.js", "max_stars_repo_name": "marcus13345/Collexion", "max_stars_repo_stars_event_min_datetime": "2021-05-06T22:21:42.000Z", "max_stars_repo_stars_event_max_datetime": "2021-05-06T22:21:42.000Z", "max_issues_repo_path": "core/Item.js", "max_issues_repo_name": "marcus13345/Collexion", "max_issues_repo_issues_event_min_datetime": "2019-10-23T01:44:15.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-10T18:29:08.000Z", "max_forks_repo_path": "core/Item.js", "max_forks_repo_name": "marcus13345/Collexion", "max_forks_repo_forks_event_min_datetime": "2019-10-23T01:41:35.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-23T01:41:35.000Z"}
{"max_stars_count": 1, "max_issues_count": 2, "max_forks_count": 1, "avg_line_length": 21.8888888889, "max_line_length": 61, "alphanum_fraction": 0.5979695431}
const EventEmitter = require('events');

const COLLEXION = Symbol('collexion');
const DATA = Symbol('data');
const LINKS = Symbol('links');
const EVENTEMITTER = Symbol('event-emitter');

module.exports = class Item {
	connected(collexion, data, links) {
		// console.log('Item::connected', collexion, data, links);
		this[COLLEXION] = collexion;
		this[DATA] = data;
		this[LINKS] = links;
		this[EVENTEMITTER] = new EventEmitter();

		// copy data into state
		for(const key in this[DATA]) {
			this[key] = this[DATA][key];
		}

		if(!collexion.ready) {
			collexion.on('ready', evt => {
				this.ready()
			});
		} else {
			this.ready();
		}
	}

	ready() {}

	on(...args) { this[EVENTEMITTER].on(...args) }
	off(...args) { this[EVENTEMITTER].off(...args) }
	emit(...args) { this[EVENTEMITTER].emit(...args) }

	get collexion() {
		return this[COLLEXION];
	}

	get links() {
		return this[LINKS];
	}

	get _links() { return this.links; }
}