From 3285f8b32d589a48becf63219353cec321d50bc1 Mon Sep 17 00:00:00 2001 From: marihachi Date: Sat, 27 Mar 2021 01:22:22 +0900 Subject: [PATCH] add inspect() --- src/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/index.ts b/src/index.ts index fff528e..16a2afc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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,