flummpress/dist/container.js
2025-03-25 13:50:45 +01:00

26 lines
665 B
JavaScript

export default class Container {
constructor() {
this.services = new Map();
}
<<<<<<< HEAD
set(type, instance) {
this.services.set(type, instance);
}
get(type) {
const instance = this.services.get(type);
if (!instance)
throw new Error(`Service of type "${type.name}" not found.`);
return instance;
=======
register(name, factory) {
this.services.set(name, factory);
}
resolve(name) {
const factory = this.services.get(name);
if (!factory)
throw new Error(`Service "${name}" not found.`);
return factory();
>>>>>>> 277f5a3 (test)
}
}