# hierarchy

> Convert JSON object to a beautiful string representation of a directory structure

Latest version **1.0.0** (published 2013-12-13) · 0 weekly downloads

## Install

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

Provides the command `hierarchy`.

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2013-12-13 |
| First published | 2013-12-13 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | bevacqua |

## Links

- npm: https://www.npmjs.com/package/hierarchy
- Homepage: https://github.com/bevacqua/hierarchy.git
- npm.io page: https://npm.io/package/hierarchy

## Recent versions

- 1.0.0 (latest) — 2013-12-13

## README

# hierarchy

> Convert JSON object to a beautiful string representation of a directory structure

Like [archy](https://github.com/substack/node-archy), but easier. Inspired in the text-tree [found in an answer on StackOverflow](http://stackoverflow.com/a/20408498/389745).

# Installation

```shell
npm i --save hierarchyjs
```

# Usage

Considering the `input.json` file:

```json
{
    "foo": {
        "bar": {
            "$files": ["baz.js", "piece.js"]
        },
        "paz": {}
    },
    "baz": {
        "$files": ["taz.js"]
    },
    "$files": ["Gruntfile.js", "package.json"]
}
```

## From the command line

```shell
hierarchy input.json
```

## In code

```js
var hierarchy = require('hierarchy');
var input = require('input.json');
var tree = hierarchy(input);

console.log(tree);
```

# Notation

The input is expected to be a tree-like object with optional `$files` arrays that describe a list of files in a directory. The `$files` construct can actually be avoided by treating files as empty directories, but its a little convenience sugar.

The following has the exact same output as the previous example.

```json
{
    "foo": {
        "bar": {
            "$files": {
                "baz.js": {},
                "piece.js": {}
            },
        },
        "paz": {}
    },
    "baz": {
        "taz.js": {}
    },
    "Gruntfile.js": {},
    "package.json": {}
}
```

A file named `$etc` might be used to include a "and more.." `'....'` kind of message.

# License

MIT

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