Skip to content

vasiliyaltunin/arboreal.js

 
 

Repository files navigation

NPM

Arboreal.js Built with Grunt

Build Status GitHub license dependencies Status devDependencies Status

A micro-library for traversing and manipulating tree-like data structures in JavaScript, works with both node.js and the browser.

(Forked from Nenad V. Nikolić, originally by Andrea Fiore)

Installation

Install via npm:

% npm install arboreal.js

Usage

Add script to you webpage

<script src="../lib/arboreal.min.js" type="text/javascript"></script>

Arboreal.js provides a set of methods for parsing, manipulating, and traversing tree like data structures. A tree can be created from scratch and then extended with child elements.

var tree = new Arboreal(null, {category: 'JavaScript'});

tree.appendChild({category: 'Ajax (programming)'})
        .appendChild({category: 'JavaScript engines'})
        .appendChild({category: 'JavaScript programming languages family'})
            .children[2]
            .appendChild({category: 'JavaScript dialect engines'})
        .parent
        .appendChild({category: 'JavaScript based calendar components'})
        .appendChild({category: 'JavaScript based HTML editors'});

For each child node, Arboreal.js will automatically assign an id string representing the depth and the index the position of the node within the tree structure.

0 {"category":"JavaScript"}
 |- 0/0 {"category":"Ajax (programming)"}
 |- 0/1 {"category":"JavaScript engines"}
 |- 0/2 {"category":"JavaScript programming languages family"}
  |- 0/2/0  {"category":"JavaScript dialect engines"}
 |- 0/3 {"category":"JavaScript based calendar components"}
 |- 0/4 {"category":"JavaScript based HTML editors"}

Check our wiki for more usage examples.

Check our documentation

Also check this demo.

Contributing

Here's a quick guide:

  1. Fork the repo

  2. npm install

  3. grunt

  4. Make you changes and add test for you functionality. Look into /test folder.

  5. Check that all test passed by running grunt

  6. Push to your fork and submit a pull request.

Minfication

A minified version generated into /lib when you run grunt

Licence

Released under MIT License - https://opensource.org/licenses/MIT

About

Javascript tree-traversal and manipulation microlibrary

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • JavaScript 97.2%
  • HTML 2.8%