MCPcopy
hub / github.com/markmap/markmap / walkTree

Function walkTree

packages/markmap-common/src/util.ts:14–25  ·  view source on GitHub ↗
(
  tree: T,
  callback: (item: T, next: () => U[] | undefined, parent?: T) => U,
)

Source from the content-addressed store, hash-verified

12}
13
14export function walkTree<T extends { children?: T[] }, U = void>(
15 tree: T,
16 callback: (item: T, next: () => U[] | undefined, parent?: T) => U,
17): U {
18 const walk = (item: T, parent?: T): U =>
19 callback(
20 item,
21 () => item.children?.map((child: T) => walk(child, item)),
22 parent,
23 );
24 return walk(tree);
25}
26
27export function addClass(className: string, ...rest: string[]): string {
28 const classList = (className || '').split(' ').filter(Boolean);

Callers 5

toggleNodeMethod · 0.90
_initializeDataMethod · 0.90
renderDataMethod · 0.90
setOriginNodeMethod · 0.90
convertNodeFunction · 0.90

Calls 1

walkFunction · 0.85

Tested by

no test coverage detected