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

binary-tree

v0.2.0

Published

Methods for working with binary search tree. Support for duplication.

Downloads

2

Readme

BinaryTree

0.2.0

npm install binary-tree git clone https://github.com/vancivelik/BinaryTree.git

Terms

node = [address, key, left, right]

Address is a string or a number

address is Address

key is a number

left and right is Address or null

if left or right is a null then right subtree is empty

handler is a function

direction indicates the direction, 1 indicates to the left, 2 indicates to the right

duplicating rule indicates duplicating of nodes, 0 disables duplication, 1 includes left, 2 includes right

merging rule indicates merging of nodes, works as direction

debug is a boolean, indicates throw any errors

Handler variants

(null, null) -> not found

(node, null) -> last node

(node, next) -> not last node

the last returned node - the target node

Construct

Server

BinaryTree = require 'binary-tree'

Client

require ['binary-tree'], (BinaryTree) ->

Usage

it gives full modularity

getNode = (address, callback) -> callback node # return the node address - address
setLeft = (address, leftLink, callback) ->
	# set at the left sub-node with address - address
	callback node # return the set via the node as getNode
setRight = (address, rightLink, callback) ->
	# set at the right sub-node with address - address
	callback node # return the set via the node as getNode
setNode = (address, leftLink, rightLink, callback) ->
	# set both the left and right subtree of a node with address - address
	callback node # return the set via the node as getNode
getRoot = (callback) -> callback root
setRoot = (link, callback) ->
	# use the link on the root
	callback link

new BinaryTree getNode, setLeft, setRight, setNode, getRoot, setRoot, duplicating, merging, debug

an example can be seen in the test file Tests.coffee Tests.coffee or Tests.js

to run the tests, you can try vows Tests.coffee --spec in console

if you use grunt in console, the main file and the test file will be compiled automatically

Instance

instance.unsafe.travel node, (node, next) -> next node instance.unsafe.corner node source, direction, (node, next) -> do next instance.unsafe.merge node left, node right, (node, next) -> do next instance.search key target, (node, next) -> do next instance.safe.search node target, (node, next) -> do next handler instance.unsafe.search node source, node target, (node, next) -> do next instance.attach key target, (node, next) -> do next instance.safe.attach node target, (node, next) -> do next instance.unsafe.attach node source, node target, (node, next) -> do next instance.detach address target, (node, next) -> do next instance.safe.detach node target, (node, next) -> do next instance.unsafe.detach node source, node target, (node, next) -> do next

Changes

0.2.0

Fork Van Civelik.

Require.js support.

0.1.2

Improved documentation.

0.1.1

In the constructor method is added setNode, immediately setting the left and right subtree, for increased productivity.

0.1.0

Written including, possibly, all behaviors.

Written library performs tests.

The library can be used as a node.js module.

Custom methods passed to the constructor transferred to the sub-object instance.user.