🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

treeify

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
t

treeify

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

1.1.0
latest
100

Supply Chain Security

100

Vulnerability

93

Quality

76

Maintenance

100

License

Version published
Weekly downloads
1.6M
-1.51%
Maintainers
1
Weekly downloads
 
Created
Issues
6

What is treeify?

The treeify npm package is used to convert a flat, nested object into a visual tree structure. This can be useful for displaying hierarchical data in a more readable format, such as in command-line tools or debugging outputs.

What are treeify's main functionalities?

Convert object to tree

This feature allows you to convert a nested object into a string that visually represents a tree structure. The 'asTree' method takes the object and a boolean indicating whether to show empty values.

const treeify = require('treeify');
let tree = treeify.asTree({hello: 'world', foo: {bar: 'baz'}}, true);
console.log(tree);

Custom sorting of tree branches

This feature allows you to provide a custom sorting function for the keys of your object, which will affect the order in which branches are displayed in the tree.

const treeify = require('treeify');
let tree = treeify.asTree({foo: {bar: 'baz'}, hello: 'world'}, true, (a, b) => a.localeCompare(b));
console.log(tree);

Other packages similar to treeify

FAQs

Package last updated on 16 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts