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

@vulppi/node-tree

v0.5.0

Published

A simple tree data structure for typescript

Downloads

10

Readme

Vulppi Tree Node

Installation

npm add @vulppi/node-tree

Methods & Properties

Properties

| Name | Type | Default | | --------------------------- | -------------------------- | ----------- | | id | readonly string | none | | name | string | undefined | | parent | VulppiNode | null | | prevSibling | VulppiNode | null | | nextSibling | VulppiNode | null | | flags | {[key: string]: boolean} | {} | | properties | {[key: string]: any} | {} |

Methods

| Name | Type | | ----------------------------------------- | ------------------------------------------------------------- | | destroy | (): void | | clone | (): VulppiNode | | getChildren | (): VulppiNode[] | | addChild | (child: VulppiNode, index?: number): void | | getChild | (index: number \| string \| VulppiNode): VulppiNode \| null | | removeChild | (index: number \| VulppiNode): VulppiNode \| null | | addInRoot | (child: VulppiNode, index?: number): void | | contains | (child: VulppiNode): boolean | | findIndex | (child: VulppiNode): number | | findChild | (id: string): VulppiNode \| null | | findByName | (name: string): VulppiNode[] | | on | (event: string, cb: Function): void | | off | (event: string, cb: Function): Function \| null | | isEmpty | (): boolean | | isPropsEmpty | (): boolean | | isFlagsEmpty | (): boolean | | isAllEmpty | (): boolean | | mergeToParent | (): void | | toObject | (): ParsedNode | | toJSON | (): string | | static fromObject | (data: ParsedNode): VulppiNode | | static fromJSON | (data: string): VulppiNode |

Properties Description

id

Unique identifier among its sibling nodes.

It's a required field in the node's constructor.

name

It is an optional field to find the node in the entire tree, returning a list of nodes with the same name.

parent

If the node has a parent, this property points to its parent. If not, the property is null.

nextSibling

If the node has a next sibling, this property points to its node. Otherwise the property is null.

prevSibling

If the node has a previous sibling, this property points to its node. Otherwise the property is null.

flags

This property allows receiving boolean flags.

properties

Location where our data is assigned.

This field can also be typed.

interface MyNodeProps {
  foo: string
}

const myNode = new VulppiNode<MyNodeProps>('my-id')

myNode.properties.foo = 'bar'

Methods Description

destroy

This method destroys the node and removes it from the tree.

clone

Cleanly clone the node and all of its children.

getChildren

This method brings up the list of children.

getRoot

This method brings up the root parent.

addChild

Method for adding a new child to the node's child list.

If a node with the same ID is found, it will be merged with the existing node.

There is also the possibility to add the child in a specific position.

getChild

Retrieves a child from position or an ID.

removeChild

Removes a child from its position or the child's own.

addInRoot

This method allows you to add a node to the tree's main node list.

contains

Check whether the node is contained in the tree.

findIndex

Returns our son's position if found.

findChild

Finds a child node from its ID.

findByName

Returns a list of nodes that have the same name within the tree.

on

Add an event point to the node.

off

Remove an event point to the node.

isEmpty

Check if the node has any children.

isPropsEmpty

Check if the node has any property.

isFlagsEmpty

Check if the node has any flag.

isAllEmpty

Check that the node has no children, no properties, and no flags.

mergeToParent

This method allows the node to merge with its parent.

toObject

Converts the node to a clean object.

toJSON

Converts the node into a json object in string.

static fromObject

Creates a new node from an object.

static fromJSON

Creates a new node from an JSON string.