UNPKG

@visactor/vrender-core

Version:

```typescript import { xxx } from '@visactor/vrender-core'; ```

16 lines (15 loc) 535 B
export class GraphicFactory { constructor() { this.registry = new Map; } create(type, attributes) { const GraphicCtor = this.registry.get(type); if (!GraphicCtor) throw new Error(`GraphicFactory has no creator registered for type "${type}"`); return new GraphicCtor(attributes); } register(type, ctor) { if (!type) throw new Error("GraphicFactory requires a non-empty graphic type"); this.registry.set(type, ctor); } } //# sourceMappingURL=graphic-factory.js.map