mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-25 07:25:13 +00:00
add inspect()
This commit is contained in:
parent
28841ea930
commit
3285f8b32d
1 changed files with 9 additions and 0 deletions
|
@ -24,6 +24,15 @@ export function toString(node: MfmNode | MfmNode[]): string {
|
|||
}
|
||||
}
|
||||
|
||||
export function inspect(tree: MfmNode[], action: (node: MfmNode) => void): void {
|
||||
for (const node of tree) {
|
||||
action(node);
|
||||
if (node.children != null) {
|
||||
inspect(node.children, action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
MfmNode,
|
||||
MfmBlock,
|
||||
|
|
Loading…
Reference in a new issue