UNPKG

@open-audio-stack/core

Version:
40 lines (39 loc) 955 B
import { Base } from './Base.js'; export class Registry extends Base { name; url; version; managers; constructor(name, url, version) { super(); this.name = name; this.url = url; this.version = version; this.managers = {}; } addManager(manager) { this.managers[manager.type] = manager; } getManager(type) { return this.managers[type]; } reset() { Object.values(this.managers).forEach(manager => manager.reset()); } async sync() { for (const [, manager] of Object.entries(this.managers)) { await manager.sync(); } } toJSON() { const data = { name: this.name, url: this.url, version: this.version, }; for (const [type, manager] of Object.entries(this.managers)) { data[type] = manager.toJSON(); } return data; } }