fast-archy
v1.1.1
Published
render nested hierarchies `npm ls` style with unicode pipes
Downloads
37,191
Maintainers
Readme
fast-archy
Render nested hierarchies npm ls style with unicode pipes.
Rewrite of archy in TypeScript, making it faster.
Install
npm install fast-archyUsage
import archy from "fast-archy";
const s = archy({
label: "beep\none\ntwo",
nodes: [
"ity",
{
label: "boop",
nodes: [
{
label: "o_O\nwheee",
nodes: [
{
label: "oh",
nodes: ["hello", "puny\nmeat"],
},
"creature",
],
},
"party\ntime!",
],
},
],
});
console.log(s);Output:
beep
│ one
│ two
├── ity
└─┬ boop
├─┬ o_O
│ │ wheee
│ ├─┬ oh
│ │ ├── hello
│ │ └── puny
│ │ meat
│ └── creature
└── party
time!API
archy(obj, prefix?, opts?)
objobject|string- Tree object or string label.obj.labelstring- Node label.obj.nodesarray- Array of child nodes (same structure asobj).
prefixstring- Custom prefix for tree branches (default:"").optsobject- Options object.opts.unicodeboolean- Use Unicode characters (default:true). Iffalse, uses ASCII characters.
Benchmarks
clk: ~4.00 GHz
cpu: 13th Gen Intel(R) Core(TM) i5-13400F
runtime: node 26.5.0 (x64-win32)
benchmark avg (min … max) p75 / p99 (min … top 1%)
------------------------------------------- -------------------------------
• archy - simple tree
------------------------------------------- -------------------------------
fast-archy 59.71 ns/iter 62.79 ns 107.23 ns █▆▅▂▂▁▁▁▁▁▁
archy 448.96 ns/iter 451.76 ns 626.10 ns ▆█▄▂▁▁▁▁▁▁▁
summary
fast-archy
7.52x faster than archy
• archy - medium tree
------------------------------------------- -------------------------------
fast-archy 271.60 ns/iter 274.68 ns 383.20 ns ▂█▇▃▂▂▁▁▁▁▁
archy 2.69 µs/iter 2.75 µs 2.90 µs ▂▂▂▄▆██▅▃▁▂
summary
fast-archy
9.92x faster than archy
• archy - complex tree
------------------------------------------- -------------------------------
fast-archy 431.70 µs/iter 443.60 µs 602.40 µs ██▃▃▂▁▁▁▁▁▁
archy 1.26 ms/iter 1.27 ms 1.67 ms ▁▂█▄▂▂▁▁▁▁▁
summary
fast-archy
2.91x faster than archy
• archy - ascii mode
------------------------------------------- -------------------------------
fast-archy (ascii) 267.55 ns/iter 271.22 ns 374.34 ns ▃█▆▃▂▁▁▁▁▁▁
archy (ascii) 3.03 µs/iter 3.08 µs 3.24 µs ▃▃▄██▇▆▃▁▁▂
summary
fast-archy (ascii)
11.32x faster than archy (ascii)
• archy - beepHexo
------------------------------------------- -------------------------------
fast-archy 866.10 µs/iter 893.00 µs 1.13 ms ▅██▇▃▂▁▁▁▁▁
archy 9.81 ms/iter 9.95 ms 10.53 ms ▂▃▆█▇▇▄▃▂▂▁
summary
fast-archy
11.33x faster than archyLicense
MIT
