add inspect()

This commit is contained in:
marihachi 2021-03-27 01:22:22 +09:00
parent 28841ea930
commit 3285f8b32d

View file

@ -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 { export {
MfmNode, MfmNode,
MfmBlock, MfmBlock,