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

displayastree

Package Overview
Dependencies
Maintainers
3
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

displayastree

Simple way to display data as a tree structure.

  • 3.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

DisplayAsTree

NPM Version CI Status Coverage

Simple way to display data as a tree structure.


Display As Tree
Screenshot taken from DevScript to be used as an example.

Compatability

You are able to pass strings that are colored using Chalk.

Installation

# global
npm i -g displayastree

# npm
npm i displayastree

# yarn
yarn add displayastree

Usage

Tree with inner sections:

import { Tree, Branch } from "displayastree";

//* Chalk is not needed but is just used in this example.
import chalk from "chalk";

//* Make the main tree.
const tree = new Tree(chalk.hex("#FF8C00")("Found 2 TODO's"));

//* Make branches.
const branchOne = new Branch(chalk.cyan("config.ts")).addBranch([chalk.yellow("src/config.ts")]);
const branchTwo = new Branch(chalk.cyan("index.ts")).addBranch([chalk.yellow("src/modules/status/index.ts")]);

//* Add the branches to the main tree and log
tree.addBranch([branchOne, branchTwo]).log();

Will log:
Display As Tree

Tree without inner sections:

new Tree("A test").addBranch(["a", "b", "c"]).log();

Will log:
Display As Tree

Options

Simply include the options while creating the Tree instance.

const tree = new Tree("Tree Name", { headChar: "* " });
OptionsTypeDescriptionDefault
headCharstringString of the character that the tree will start with.
treeCharstringString of the character that the tree will split with.├─
lineCharstringString of the character that the tree will display at overlaps.
lastCharstringString of the character that the tree will end with.╰─

Note: treeChar, lineChar, and lastChar must have the same length.

Keywords

FAQs

Package last updated on 17 Feb 2024

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