mirror of
https://github.com/chylex/objtree.git
synced 2025-05-21 18:34:03 +02:00
JavaScript snippet that generates a nicely formatted representation of an object tree.
LICENSE.md | ||
objtree.js | ||
README.md |
objtree
is a script that generates a text tree representation of an object. The script can be executed in a browser console.
How to Use
var target = {};
var result = objtree(target, {
// Maximum level of recursion
maxlevel: 10,
// Prefixed before every name (ex. window)
grandparent: "",
// Array of strings (behaving like regular expressions) matched against names to exclude
// Use / to separate nested objects (ex. {a:{b:{c:true}}} will be a/b/c)
// Note that grandparent is not included in the name matching process
exclude: []
});
result.asObj(); // returns internal representation of the tree
result.asText(); // returns a formatted text representation
result.downloadText(filename); // triggers a browser file download with the formatted text
Examples
TODO