vat-tree

0.1.2 • Public • Published

vat-tree

A tree data structure with ordered branches. It can be used client and server side.

Installation

$ npm install vat-tree

Quick Start

  var Node = require('vat-tree').Node
  var Position = require('vat-tree').Position

  var tree = new Node({}, true); // 'true' means its a root node
  var child1 = new Node()
  var child2 = new Node()

  tree.addChild(child1)
  tree.addChild(child2)

  child1.getNextSibling() == child2 //it is true!
  tree.addChildAtPosition(new Node(), 1)
  tree.moveNode(child1, child2, Position.AFTER);

Features

  • Initialize from json data
  • Move a node to a new location
  • Get previous and next sibling
  • Add a node before or after a already exsisting node
  • Iterate and filter functions

Running Tests

To run the test suite, first invoke the following command within the repo, installing the development dependencies:

$ npm install

Then run the tests:

$ npm test

Credits

This library was forked from part of jqTree under the Apache 2.0 lisence. It has since been modified from the original. This project's notice file links to the exact file.

Package Sidebar

Install

npm i vat-tree

Weekly Downloads

2

Version

0.1.2

License

Apache 2.0

Last publish

Collaborators

  • victorsigma