MCPcopy Index your code
hub / github.com/codemix/graph / instantiateResult

Method instantiateResult

packages/graph/src/AsyncGraph.ts:112–138  ·  view source on GitHub ↗
(result: TransportableValue)

Source from the content-addressed store, hash-verified

110 }
111
112 protected instantiateResult<TPath>(result: TransportableValue): TPath {
113 switch (result["@type"]) {
114 case "TraversalPath": {
115 let value: any = result.value;
116 if (value != null && "@type" in value) {
117 value = this.instantiateResult(value);
118 }
119 return new TraversalPath(
120 result.parent == null ? undefined : this.instantiateResult(result.parent),
121 value,
122 result.labels,
123 ) as TPath;
124 }
125 case "Vertex":
126 this.#storage.push(result);
127 return this.#graph.getVertexById(result.id) as TPath;
128 case "Edge":
129 this.#storage.push(result);
130 return this.#graph.getEdgeById(result.id) as TPath;
131 case "AsyncOperationSuccess":
132 return undefined as TPath;
133 case "AsyncOperationFailure":
134 throw new Error(result.error);
135 default:
136 throw new Error(`Unknown result type: ${result["@type"]}`);
137 }
138 }
139}
140
141class AsyncGraphStorage extends InMemoryGraphStorage {

Callers 1

queryMethod · 0.95

Calls 3

getVertexByIdMethod · 0.65
getEdgeByIdMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected