MCPcopy Create free account
hub / github.com/Calamari/BehaviorTree.js / parse

Method parse

src/BehaviorTreeImporter.js:31–49  ·  view source on GitHub ↗
(json)

Source from the content-addressed store, hash-verified

29 }
30
31 parse(json) {
32 const { type, name, node, nodes, ...config } = json
33 const Klass = this.types[type]
34 if (!Klass) {
35 const registeredNode = registryLookUp(type)
36 if (registeredNode) {
37 registeredNode.name = name
38 return registeredNode
39 }
40 throw new Error(`Don't know how to handle type ${type}. Please register this first.`)
41 }
42
43 return new Klass({
44 name: name,
45 node: node ? this.parse(node) : null,
46 nodes: nodes ? nodes.map((subJson) => this.parse(subJson)) : null,
47 config
48 })
49 }
50}

Callers 1

Calls 1

registryLookUpFunction · 0.90

Tested by

no test coverage detected