MCPcopy Create free account
hub / github.com/compilets/compilets / filterNode

Function filterNode

src/parser-utils.ts:298–312  ·  view source on GitHub ↗
(node?: ts.Node,
                           predicate?: (node: ts.Node) => boolean,
                           isLeaf: (node: ts.Node) => boolean = isFunctionLikeNode)

Source from the content-addressed store, hash-verified

296 * Helper to get all the child nodes.
297 */
298export function filterNode(node?: ts.Node,
299 predicate?: (node: ts.Node) => boolean,
300 isLeaf: (node: ts.Node) => boolean = isFunctionLikeNode) {
301 const results: ts.Node[] = [];
302 if (!node)
303 return results;
304 const visit = (node: ts.Node) => {
305 if (!predicate || predicate(node))
306 results.push(node);
307 if (!isLeaf(node))
308 ts.forEachChild(node, visit);
309 };
310 visit(node);
311 return results;
312}
313
314/**
315 * Parse comment hints like "// compilets: destructor".

Callers 2

Calls 1

visitFunction · 0.85

Tested by

no test coverage detected