MCPcopy
hub / github.com/loggerhead/json4u / newNode

Method newNode

src/lib/parser/parse.ts:165–187  ·  view source on GitHub ↗
(path: jsonc.JSONPath, type: NodeType, offset: number, length: number = 0)

Source from the content-addressed store, hash-verified

163 }
164
165 newNode(path: jsonc.JSONPath, type: NodeType, offset: number, length: number = 0) {
166 const node: ParseNode = {
167 id: toPointer(path),
168 type,
169 offset,
170 length,
171 keyLength: 0,
172 boundOffset: offset,
173 boundLength: length,
174 path,
175 parent: this.currentParent,
176 };
177
178 if (isIterable(node)) {
179 node.childrenKeys = [];
180 node.childrenKey2Id = {};
181 node.childrenOffset = {};
182 node.childrenKeyLength = {};
183 }
184
185 this.nodeMap[node.id] = node;
186 return node;
187 }
188
189 setValue(node: ParseNode, value: any, offset: number, length: number) {
190 node.value = value;

Callers 2

onObjectBeginMethod · 0.95
onLiteralValueMethod · 0.95

Calls 2

toPointerFunction · 0.90
isIterableFunction · 0.90

Tested by

no test coverage detected