0.0.7 • Published 6 months ago

@casd/print-tree v0.0.7

Weekly downloads
-
License
GPL-3.0-only
Repository
github
Last release
6 months ago

Print tree

Create a plain text tree, like the tree command commonly found on UNIX-like opertating systems.

How to install

Using npm:
npm install --save-dev @casd/print-tree

Using yarn:
yarn add --dev @casd/print-tree

How to use

import { printTreesFromString } from '@casd/print-tree';
// or using require()
// const { printTreesFromString } = require('@casd/print-tree');

// Default indentation is two spaces per level
const inputString = `
Root
  Child
    Grandchild`;

const treeString = printTreesFromString(inputString)

/* Value of treeString:

Root
└── Child
    └── Grandchild

*/
import { printTrees } from '@casd/print-tree';

const inputNodes = [
  { value: 'Root', children: [{ value: 'Child', children: [{ value: 'Grandchild' }] }] }
];

const treeString = printTrees(inputNodes);
// treeString is the same value as the example above
import { printTree } from '@casd/print-tree';

const inputNode = { value: 'Root', children: [{ value: 'Child', children: [{ value: 'Grandchild' }] }] };

const treeString = printTree(inputNode);
// treeString is the same value as the example above
0.0.7

6 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago