# treeify

> converts a JS object into a nice and readable tree structure for the console

Latest version **1.1.0** (published 2018-02-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install treeify
pnpm add treeify
yarn add treeify
bun add treeify
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2018-02-16 |
| First published | 2012-09-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/treeify) |
| Module format | CommonJS |
| Node | >=0.6 |
| Dependencies | 0 |
| Unpacked size | 21.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 262 |
| Author | Luke Plaster |
| Maintainers | notatestuser |
| Keywords | object, tree, print, console, pretty |

## Links

- npm: https://www.npmjs.com/package/treeify
- Repository: https://github.com/notatestuser/treeify
- Homepage: https://github.com/notatestuser/treeify#readme
- Issues: https://github.com/notatestuser/treeify/issues
- npm.io page: https://npm.io/package/treeify

## Recent versions

- 1.1.0 (latest) — 2018-02-16
- 1.0.1 — 2013-04-06
- 1.0.0 — 2013-03-30
- 0.4.2 — 2012-12-27
- 0.4.1 — 2012-12-24
- 0.4.0 — 2012-12-24
- 0.3.0 — 2012-12-23
- 0.2.0 — 2012-10-25
- 0.1.1 — 2012-10-01
- 0.1.0 — 2012-09-30

## README

treeify ![](https://img.shields.io/npm/v/treeify.svg) ![](https://img.shields.io/npm/dt/treeify.svg)
=======

[![Build Status](https://travis-ci.org/notatestuser/treeify.png?branch=master)](https://travis-ci.org/notatestuser/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.

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:
```js
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()
```js
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()
```js
treeify.asTree(obj, showValues (boolean), hideFunctions (boolean)): String
```

Running the tests
-----------------

There's a pretty extensive suite of Vows tests included.
```
$ npm test
```

---
_Source: https://npm.io/package/treeify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
