flummpress/dist/container.js
2025-03-24 14:35:08 +01:00

15 lines
358 B
JavaScript

export default class Container {
constructor() {
this.services = new Map();
}
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();
}
}