Tree Node
Simple tree data structure in JS, designed specifically to organize related data in such a way that it can be consumed
by tree diagram visualizations, and so that "leaf" nodes (endpoints) can be quickly identified.
Installation
npm install treenode --save
Usage
var TreeNode = require('treenode').TreeNode;
var tree = new TreeNode({id: 0, name: 'root'});
tree.addChild({id: 1, name: 'Node 1'});
var child = tree.addChild({id: 2, name: 'Node 2'});
child.addChild({id: 3, name: 'Node 3' });
var leaves = tree.leaves();
var node = tree.addChild(someObject);
var match = tree.findNode(someObject);
var root = node.root();
node.forEach(function(element) {
element.data.status='processed';
});
Tests
npm test
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed
functionality. Lint and test your code.
Release History
- 0.2.1 Remove sourcemaps from non-minified prod file
- 0.2.0 Add forEach() to execute a function on each node in a tree
- 0.1.4 Better module export syntax
- 0.1.3 Updated packaging for Bower
- 0.1.2 Updated packaging
- 0.1.1 Updated packaging
- 0.1.0 Initial release