fast-archy
render nested hierarchies `npm ls` style with unicode pipes
Last updated a month ago by GitHub Actions .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install fast-archy 
SYNC missed versions from official npm registry.

fast-archy

npm bundle size npm NPM

Render nested hierarchies npm ls style with unicode pipes.

Rewrite of archy in TypeScript, making it faster.

Install

npm install fast-archy

Usage

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?)

  • obj object|string - Tree object or string label.
    • obj.label string - Node label.
    • obj.nodes array - Array of child nodes (same structure as obj).
  • prefix string - Custom prefix for tree branches (default: "").
  • opts object - Options object.
    • opts.unicode boolean - Use Unicode characters (default: true). If false, 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 archy

License

MIT

Current Tags

  • 1.1.1                                ...           latest (a month ago)

3 Versions

  • 1.1.1                                ...           a month ago
  • 1.1.0                                ...           4 months ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Total 5
Today 0
This Week 0
This Month 4
Last Day 0
Last Week 1
Last Month 1
Dependencies (0)
None
Dev Dependencies (9)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE