0.0.7 • Published 11 months ago

@casd/print-tree v0.0.7

Weekly downloads
-
License
GPL-3.0-only
Repository
github
Last release
11 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

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago