MCPcopy Create free account
hub / github.com/block/buzz / walkChildren

Function walkChildren

desktop/src/shared/lib/createRemarkPrefixPlugin.ts:35–59  ·  view source on GitHub ↗
(node: any, pattern: RegExp, buildNode: NodeBuilder)

Source from the content-addressed store, hash-verified

33
34// biome-ignore lint/suspicious/noExplicitAny: remark tree types are not available
35function walkChildren(node: any, pattern: RegExp, buildNode: NodeBuilder) {
36 if (
37 !node?.children ||
38 !Array.isArray(node.children) ||
39 shouldSkipNode(node)
40 ) {
41 return;
42 }
43
44 for (let i = node.children.length - 1; i >= 0; i--) {
45 const child = node.children[i];
46
47 if (child.type === "text") {
48 const parts = splitByPattern(child.value, pattern, buildNode);
49 if (
50 parts.length > 1 ||
51 (parts.length === 1 && parts[0].type !== "text")
52 ) {
53 node.children.splice(i, 1, ...parts);
54 }
55 } else {
56 walkChildren(child, pattern, buildNode);
57 }
58 }
59}
60
61// biome-ignore lint/suspicious/noExplicitAny: remark tree types are not available
62function shouldSkipNode(node: any): boolean {

Callers 1

createRemarkPrefixPluginFunction · 0.70

Calls 2

shouldSkipNodeFunction · 0.70
splitByPatternFunction · 0.70

Tested by

no test coverage detected