1
0
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.
Go to file
2017-07-23 15:09:55 +02:00
LICENSE.md Rename LICENSE to LICENSE.md 2017-07-23 14:39:04 +02:00
objtree.js Push objtree.js 2017-07-23 14:58:39 +02:00
README.md Create README.md 2017-07-23 15:09:55 +02:00

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