lion/packages/singleton-manager/src/SingletonManagerClass.js
Thomas Allmer 7f49f2c6a6 feat: manager to support single instances with nested npm installations
BREAKING CHANGE: add singleton-manager
2020-05-18 15:25:21 +02:00

20 lines
362 B
JavaScript

export class SingletonManagerClass {
constructor() {
this._map = new Map();
}
set(key, value) {
if (this.has(key)) {
throw new Error(`The key "${key}" is already defined and can not be overridden.`);
}
this._map.set(key, value);
}
get(key) {
return this._map.get(key);
}
has(key) {
return this._map.has(key);
}
}