all files / model/data/ NodeFactory.js

0% Statements 0/5
0% Branches 0/2
0% Functions 0/2
0% Lines 0/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17                                 
class NodeFactory {
 
  constructor(nodeRegistry) {
    this.nodeRegistry = nodeRegistry
  }
 
  create(nodeType, nodeData) {
    var NodeClass = this.nodeRegistry.get(nodeType)
    if (!NodeClass) {
      throw new Error('No Node registered by that name: ' + nodeType)
    }
    return new NodeClass(nodeData)
  }
}
 
export default NodeFactory