0.5.11 • Published 4 years ago

nodetree-js v0.5.11

Weekly downloads
61
License
-
Repository
github
Last release
4 years ago

nodetree-js

Library for node tree building, navigation and serialization

Installation

To start using Nodetree-JS in your website, simply install it as a Node.js module:

$ npm install --save nodetree-js

Using Nodetree-JS

In the browser, getting started is as simple as:

const oNodeBase = Nodetree.createNode( 'id_myNode_base', { some_attribute: 'base' } );

In Node.js, you'll need to require() it first:

const Nodetree = require( 'nodetree-js' )
const oNodeBase = Nodetree.createNode( 'id_myNode_base', { some_attribute: 'base' } );

Usage

const oNodeBase = Nodetree.createNode( 'id_myNode_base', { some_attribute: 'base' } );

const oNodeChild_1 = Nodetree.createNode( 'id_myNode_child_1' );
const oNodeChild_2 = Nodetree.createNode( 'id_myNode_child_2' );
const oNodeChild_3 = Nodetree.createNode( 'id_myNode_child_3' );
const oNodeChild_4 = Nodetree.createNode( 'id_myNode_child_4' );

oNodeBase.append( oNodeChild_1 );
oNodeBase.prepend( oNodeChild_2 );
oNodeBase.insertAtPosition( oNodeChild_3, 1);

oNodeChild_1.append( oNodeChild_4 );

// serialize
const sSerialized = oNodeBase.toString();
// get hashcode of the node tree
const sHashCode = oNodeBase.hashcode();
// create a new node tree from a serialized one
const oNewNodeTree = Nodetree.loadFromString( sSerialized );

// get a node inside the tree with the id
oNodeChild_4 = oNewNodeTree.getElementById( 'id_myNode_child_4' );
0.5.11

4 years ago

0.5.10

5 years ago

0.5.9

5 years ago

0.5.8

5 years ago

0.5.7

5 years ago

0.5.6

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago