npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tree-node

v0.2.3

Published

tree node

Downloads

95

Readme

tree-node

tree node link HTML Node class.

component install

component install brighthas/tree-node

Node.js install

npm install tree-node

API

require
var Node = require("tree-node");
    
create
var node = new Node();
#createChild()
var rootNode = new Node();
var childNode = root.createChild();
    
#getNode(childId)
return a node. if no return null.
#appendChild(child)
var rootNode = new Node();
var node = new Node();
root.appendChild(node)
    .appendChild(new Node());
        
#removeChild(childId)
var root = new Node();
var node = new Node();
root.appendChild(node)
    .removeChild(node.id);
    
#replaceNode(child,targetId)
var root = new Node();
var target = new Node();
var node2 = new Node();

root.appendChild(target);

root.replaceNode(node2,target.id);  
#position([nodeId]))
var root = new Node();
root.position(); // null , root no position.

var n1 = new Node;
var n2 = new Node;

root.appendChild(n1).appendChild(n2);

root.position(n1.id);  // 0
root.position(n2.id);  // 1
n1.position(); // 0
n2.position(); // 1
    
#layer([nodeId])
var root = new Node();        
var n1 = new Node;
var n2 = new Node;        
root.appendChild(n1).appendChild(n2);

root.layer() // 0
root.layer(n1.id) // 1
root.layer(n2.id) // 1
n1.layer() // 1
n2.layer() // 1      
    
#top()
var root = new Node();        
var n1 = new Node;
var n2 = new Node;   
var n3 = new Node;
root.appendChild(n1).appendChild(n2).appendChild(n3);

n1.position() // 0
n2.position() // 1
n3.position() // 2

root.top(n3.id);

n1.position() // 1 
n2.position() // 2
n3.position() // 0
         
#up()
var root = new Node();        
var n1 = new Node;
var n2 = new Node;   
var n3 = new Node;
root.appendChild(n1).appendChild(n2).appendChild(n3);

n1.position() // 0
n2.position() // 1
n3.position() // 2

root.up(n3.id);

n1.position() // 0 
n2.position() // 2
n3.position() // 1
    
#down()
var root = new Node();        
var n1 = new Node;
var n2 = new Node;   
var n3 = new Node;
root.appendChild(n1).appendChild(n2).appendChild(n3);

n1.position() // 0
n2.position() // 1
n3.position() // 2

root.up(n1.id);

n1.position() // 1
n2.position() // 0
n3.position() // 3
#move(movedNodeId , targetId)
var root = new Node(); 
var n1 = new Node;
var n2 = new Node;        
root.appendChild(n1)
    .appendChild(n2)
    .move(n1.id,n2.id) // move n1 into n2.
        
#prevNode([nodeId])
var root = new Node(); 
var n1 = new Node;
var n2 = new Node;        
root.appendChild(n1)
    .appendChild(n2);

n2.prevNode() === n1;  // true
root.prevNode(n2.id) === n1;  // true
    
#nextNode([nodeId])
var root = new Node(); 
var n1 = new Node;
var n2 = new Node;        
root.appendChild(n1)
    .appendChild(n2);
    
n1.nextNode() === n2;  // true
root.nextNode(n1.id) === n2;  // true
#isRoot
var root = new Node(); 
var n1 = new Node;
var n2 = new Node;        
root.appendChild(n1)
    .appendChild(n2);
    
n1.isRoot();   // false
root.isRoot();    // true
    
#data()
var node = new Node();

node.data("name","leo")
    .data({age:12});
    
node.data("name") // "leo" 
node.data("age") // 12
    
#json & #reborn(jsonObj)
var jsonObj = new Node().json;

var newNode = new Node;
newNode.reborn(jsonObj);
    

events

Event : 'child list change'
// parent is child list's parent node.
// parent is not necessarily the node , there may be child .
// childList is a Array , child ids.
node.on("child list change",function(parent,childList){
    ... ...
});
Event : 'add'
node.on("add",function(newChild,parent){
    ... ...
});
Event : "remove"
node.on("add",function(removedChild,parent){
    ... ...
});
    
Event : "data change"
node.on("add",function(node,data){
    ... ...
});

LICENSE

MIT , [email protected]