treeify
converts a JS object into a nice, visible tree structure for the console
Last updated 14 years ago by notatestuser .
MIT · Repository · Original npm · Tarball · package.json
$ npm install treeify 
SYNC missed versions from official npm registry.

node-treeify

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.

Usage

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

Running the tests

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

$ npm test

Current Tags

  • 1.1.0                                ...           latest (9 years ago)

10 Versions

  • 1.1.0                                ...           9 years ago
  • 1.0.1                                ...           14 years ago
  • 1.0.0                                ...           14 years ago
  • 0.4.2                                ...           14 years ago
  • 0.4.1                                ...           14 years ago
  • 0.4.0                                ...           14 years ago
  • 0.3.0                                ...           14 years ago
  • 0.2.0                                ...           14 years ago
  • 0.1.1                                ...           14 years ago
  • 0.1.0                                ...           14 years ago
Maintainers (1)
Downloads
Total 40
Today 0
This Week 3
This Month 19
Last Day 0
Last Week 0
Last Month 12
Dependencies (0)
None
Dev Dependencies (1)
  • vows git://github.com/Filirom1/vows.git#expect

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