# ascii-tree

> A node module for generating a text tree in ASCII

Latest version **0.3.0** (published 2015-06-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install ascii-tree
pnpm add ascii-tree
yarn add ascii-tree
bun add ascii-tree
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2015-06-28 |
| First published | 2014-07-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 39 |
| Author | Shuping LIU |
| Maintainers | liushuping |
| Keywords | tree, text, ascii, node, javascript |

## Links

- npm: https://www.npmjs.com/package/ascii-tree
- Repository: https://github.com/liushuping/ascii-tree
- Issues: https://github.com/liushuping/ascii-tree/issues
- npm.io page: https://npm.io/package/ascii-tree

## Dependencies (1)

- [freetree](https://npm.io/package/freetree.md) 0.2.2

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2015-06-28
- 0.2.0 — 2015-06-25
- 0.1.1 — 2014-07-24
- 0.1.0 — 2014-07-23
- 0.0.1 — 2014-07-20

## README

ascii-tree
==========

A node module for generating a text tree in ASCII

[![build status](https://travis-ci.org/liushuping/ascii-tree.svg)](https://travis-ci.org/liushuping/ascii-tree.svg)

This module generates an ascii tree representation for a given string bullet list.

## Generate for a given string bullet list.
```javascript
var asciitree = require('ascii-tree');
var input = '#root node\r\n##node1\r\n###\r\nnode1\r\n##node2';
var tree = asciitree.generate(str);
```
the output string `tree` will be in below representation
```
root node
├─ node1
│  └─ node11
└─ node2
```
The leading character is not necessary to be `#`, but can be any character, this is helpful to resolve the confliction between the leading character and actual content character.
```javascript
var asciitree = require('ascii-tree');
var input = '*root node\r\n**node1\r\n***\r\nnode1\r\n**node2';
var tree = asciitree.generate(str);
```
The line break charachters `\r\n` are required. 

## Generate from an input file
First prepare an input file using bullets representating a tree
```
#root node
##node1
###node11
##node2
```
again, the leading character is not necessary to be `#` but can be any character. Then process the file content with ascii-tree to generate the ascii tree
```javascript
var fs = require('fs');
var asciitree = require('ascii-tree');
var str = fs.readFileSync('input.txt', 'utf8');
var tree = asciitree.generate(str);
fs.writeFile('output.txt', tree, 'utf8');
```

## Test
Make sure `mocha` is installed globally
```
npm install mocha -g
```
Run `npm test` to run unit test
## Dependencies
ascii-tree uses [freetree](https://github.com/liushuping/freetree) for creating tree data structure from inputting text
## License
MIT

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