Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eomm/archy

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eomm/archy

render nested hierarchies `npm ls` style with unicode pipes

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

@eomm/archy

Render nested hierarchies npm ls style with unicode pipes.

JavaScript Style Guide ci

This is a fork of substack/node-archy.
The original repository doesn't exist anymore - so here is my fork. This version has an additional feature to customize the fields name of obj input.

example

const archy = require('@eomm/archy');
const 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

const archy = require('@eomm/archy')

archy(obj, prefix='', opts={ labelField: 'label', nodesField: 'nodes' })

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.

You can customize the fields name of obj specifing a string in opts.labelField and opts.nodesField, so you don't need to adapt your tree.

install

npm install @eomm/archy

license

MIT

Keywords

FAQs

Package last updated on 25 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc