MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / doEvent

Method doEvent

contributed/jsonparser/jsonparser.js:166–186  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

164
165 // Execute 'matcher events' unconditionally and 'pattern events' selectively when nodes match a pattern.
166 doEvent(event) {
167 this.matcher?.[event](this, this.node);
168 this.patterns?.forEach(pattern => {
169 let node = this.node;
170 for (const item of pattern.items) {
171 if (item !== undefined && node !== undefined) {
172 if (item.type === node.type && (item.text === undefined || item.text === node.text)) {
173 if (node.type === NodeType.root)
174 break;
175 node = node.prev;
176 }
177 else {
178 node = undefined;
179 break;
180 }
181 }
182 }
183 if (node !== undefined)
184 pattern[event](this, this.node);
185 });
186 }
187
188 // Creates a new Node with the specified type and previous node.
189 makeNode(nodeType, prev = undefined) {

Callers 4

constructorMethod · 0.95
popMethod · 0.95
pushMethod · 0.95
setTextMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected