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

QuadMap

v1.5.0

Published

A map styled quadtree

Downloads

9

Readme

QuadMap

A map-styled quadtree. Also supports multi-variables (uses collections/fast-map)

Build Status

Installation

npm install QuadMap

Usage

var QuadMap = require("QuadMap");
var quadMap = new QuadMap(top,bottom,left,right);

To insert a node

var QuadMap = require("QuadMap");
var quadMap = new QuadMap(100,-100,-100,100);

var node = {
position: {x:10,y: 20},
name: "hello",
color: {R:0,G:0,B:0}
node.id: id
}
quadMap.set(node.id,node);

To get a node

quadMap.get(id)

To get the nodes in the nodes quad

var quad = quadMap.getQuadById(id);
var nodes = quad.getNodes();

To get the nodes in a box

var box = {
top: 20,
bottom: 0,
left: -1,
right: 10,
}
var quad = quadMap.getQuadBox(box)
var nodes = quad.getNodes(true);
// Note that it is wise to set the recursive option to true, because if the box is too big for a bottom quad, then it will return a quad it fits.

To change the position variable

var QuadMap = require("QuadMap");
var quadMap = new QuadMap(100,-100,-100,100);

var node = {
pos: {x:10,y: 20}, // Note the var is now "pos" not "position". "position" is default
name: "hello",
color: {R:0,G:0,B:0}
node.id: id
}
quadMap.setPosVar("pos");
quadMap.set(node.id,node);

To change the max amount of levels

quadMap.setMaxLevel(number);

To add a variable

quadMap.addVar("something")

To add a object to a variable

quadMap.something.set(id,obj); // Note this also adds it to the MASTER nodes list

To get a list of objects in a var inside a quad

var nodes = quad.something.getNodes(recursive,keep);

Documentation

Quadmap.prototye.set(id,node)

Insert an item

Quadmap.prototype.get(id)

returns the item based on its id.

Quadmap.prototype.delete(id)

deleted the node based apon its id

Quadmap.prototype.clear(id)

clears the quadmap/quad

Quadmap.prototype.getQuad(pos)

gets the quad based apon the pos

Quadmap.prototype.getQuadBox(box)

gets the quad the box fits into

Quadmap.prototype.getNodes(recursive,include)

Gets the nodes in a quad. If recursive is true, then any nodes in quads under the quad will also be included. if include is true, then it will return an onject like below.

{ node: node, QTree: quad, compiled: true, stored: true, }

The original node can be found in the .node variable, and the QTree is the quad it resides in. Compiled and stored are system variables.

Quadmap.prototype.setPosVar(var)

sets the name of the variable to get a nodes pos from

Quadmap.prototype.setNodeIntTime(time)

sets the time in which the node update runs