All Projects → notatestuser → Treeify

notatestuser / Treeify

Licence: mit
Pretty-print a javascript object as a tree

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Treeify

Mandown
man-page inspired Markdown viewer
Stars: ✭ 173 (-0.57%)
Mutual labels:  terminal, console
Nnn
n³ The unorthodox terminal file manager
Stars: ✭ 13,138 (+7450.57%)
Mutual labels:  terminal, console
Box Cli Maker
Make Highly Customized Boxes for your CLI
Stars: ✭ 115 (-33.91%)
Mutual labels:  terminal, console
Tcharts.js
📉 Lightweight and fast terminal ASCII charts for nodejs and browser.
Stars: ✭ 172 (-1.15%)
Mutual labels:  terminal, console
Ddgr
🦆 DuckDuckGo from the terminal
Stars: ✭ 2,243 (+1189.08%)
Mutual labels:  terminal, console
Chalk Animation
🎬 Colorful animations in terminal output
Stars: ✭ 1,489 (+755.75%)
Mutual labels:  terminal, console
Tty Pie
Draw pie charts in your terminal window
Stars: ✭ 125 (-28.16%)
Mutual labels:  terminal, console
Webpack Format Messages
Beautiful formatting for Webpack messages; ported from Create React App!
Stars: ✭ 103 (-40.8%)
Mutual labels:  pretty-print, console
Galacritty
WIP GTK terminal emulator based on Alacritty
Stars: ✭ 136 (-21.84%)
Mutual labels:  terminal, console
Kubebox
⎈❏ Terminal and Web console for Kubernetes
Stars: ✭ 1,855 (+966.09%)
Mutual labels:  terminal, console
Leash
Browser Shell
Stars: ✭ 108 (-37.93%)
Mutual labels:  terminal, console
Tty Box
Draw various frames and boxes in your terminal window
Stars: ✭ 161 (-7.47%)
Mutual labels:  terminal, console
Phetch
🐭 quick lil gopher client for your terminal
Stars: ✭ 108 (-37.93%)
Mutual labels:  terminal, console
Xterm.js
A terminal for the web
Stars: ✭ 12,019 (+6807.47%)
Mutual labels:  terminal, console
Word Wrap
Wrap words to a specified length.
Stars: ✭ 107 (-38.51%)
Mutual labels:  terminal, console
Ervy
Bring charts to terminal.
Stars: ✭ 1,530 (+779.31%)
Mutual labels:  terminal, console
Dte
A small, configurable console text editor (moved to https://gitlab.com/craigbarnes/dte)
Stars: ✭ 98 (-43.68%)
Mutual labels:  terminal, console
Jvm Mon
Console-based JVM monitoring tool
Stars: ✭ 1,365 (+684.48%)
Mutual labels:  terminal, console
Lazyhub
lazyhub - Terminal UI Client for GitHub using gocui.
Stars: ✭ 133 (-23.56%)
Mutual labels:  terminal, console
Smenu
smenu started as a lightweight and flexible terminal menu generator, but quickly evolved into a powerful and versatile CLI selection tool for interactive or scripting use.
Stars: ✭ 1,906 (+995.4%)
Mutual labels:  terminal, console

treeify

Build Status

treeify converts a JS object into a nice, visible depth-indented tree for console printing. The structure generated is similar to what you get by running the tree command on Unixy platforms.

{
    oranges: {
        'mandarin': {                                          ├─ oranges
            clementine: null,                                  │  └─ mandarin
            tangerine: 'so cheap and juicy!'        -=>        │     ├─ clementine
        }                                                      │     └─ tangerine: so cheap and juicy!
    },                                                         └─ apples
    apples: {                                                     ├─ gala
        'gala': null,                                             └─ pink lady
        'pink lady': null
    }
}

It also works well with larger nested hierarchies such as file system directory trees. In fact, the fs_tree example does a pretty good job of imitating tree. Try it out!

See the other included examples or the test suite for usage scenarios.

Getting it

For use with node.js

First you'll want to run this command in your project's root folder:

$ npm install treeify

Then proceed to use it in your project:

var treeify = require('treeify');
console.log(
   treeify.asTree({
      apples: 'gala',      //  ├─ apples: gala
      oranges: 'mandarin'  //  └─ oranges: mandarin
   }, true)
);

For use in a browser

Treeify cooperates with Node, AMD or browser globals to create a module. This means it'll work in a browser regardless of whether you have an AMD-compliant module loader or not. If such a loader isn't found when the script is executed, you may access Treeify at window.treeify.

Usage

The methods exposed to you are as follows, in a strange kind of signature notation:

asLines()

treeify.asLines(obj, showValues (boolean), [hideFunctions (boolean),] lineCallback (function))
// NOTE: hideFunctions is optional and may be safely omitted - this was done to ensure we don't break uses of the previous form

asTree()

treeify.asTree(obj, showValues (boolean), hideFunctions (boolean)): String

Running the tests

There's a pretty extensive suite of Vows tests included.

$ npm test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].