@visactor/vrender-core
Version:
```typescript import { xxx } from '@visactor/vrender-core'; ```
24 lines (20 loc) • 684 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.GraphicFactory = void 0;
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);
}
}
exports.GraphicFactory = GraphicFactory;
//# sourceMappingURL=graphic-factory.js.map