1. archy
render nested hierarchies `npm ls` style with unicode pipes
archy
Package: archy
Created by: substack
Last modified: Sun, 05 Mar 2023 20:15:52 GMT
Version: 1.0.0
License: MIT
Downloads: 26,623,686
Repository: https://github.com/substack/node-archy

Install

npm install archy
yarn add archy

archy

Render nested hierarchies npm ls style with unicode pipes.

browser support

build status

example

 var archy = require('archy');
var s = archy({
  label : 'beep',
  nodes : [
    'ity',
    {
      label : 'boop',
      nodes : [
        {
          label : 'o_O',
          nodes : [
            {
              label : 'oh',
              nodes : [ 'hello', 'puny' ]
            },
            'human'
          ]
        },
        'party\ntime!'
      ]
    }
  ]
});
console.log(s);

output

beep
├── ity
└─┬ boop
  ├─┬ o_O
  │ ├─┬ oh
  │ │ ├── hello
  │ │ └── puny
  │ └── human
  └── party
      time!

methods

var archy = require('archy')

archy(obj, prefix='', opts={})

Return a string representation of obj with unicode pipe characters like how
npm ls looks.

obj should be a tree of nested objects with 'label' and 'nodes' fields.
'label' is a string of text to display at a node level and 'nodes' is an
array of the descendents of the current node.

If a node is a string, that string will be used as the 'label' and an empty
array of 'nodes' will be used.

prefix gets prepended to all the lines and is used by the algorithm to
recursively update.

If 'label' has newlines they will be indented at the present indentation level
with the current prefix.

To disable unicode results in favor of all-ansi output set opts.unicode to
false.

install

With npm do:

npm install archy

license

MIT

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code