Skip to content

Commit

Permalink
Nicer pretty-print
Browse files Browse the repository at this point in the history
  • Loading branch information
dy committed Feb 9, 2025
1 parent 791fe55 commit 5ef5914
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function print(tree, options = {}) {

// flat node (no deep subnodes) shortcut, eg. (i32.const 1), (module (export "") 1)
if (node.length < 4 && node.every(subnode => !Array.isArray(subnode) || subnode.every(subsubnode => !Array.isArray(subsubnode))))
return `(${node.map(sn => printNode(sn)).join(' ')})`
return `(${node.map(sn => printNode(sn)).join(' ') })`

let content = node[0]

Expand All @@ -43,6 +43,6 @@ export default function print(tree, options = {}) {
}
}

return `(${content})`
return `(${content + newline + indent.repeat(level)})`
}
}

0 comments on commit 5ef5914

Please sign in to comment.