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

game-ds

v0.11.3

Published

A bunch of random utils for game development in js.

Downloads

4

Readme

A bunch of random utils for game development in js.

Classes

ArrayList

An array that auto grows, and is preallocated. It won't shrink, but will try to reuse empty elements if they have been removed.

Kind: global class

new ArrayList()

Constructor.

arrayList.count ⇒ Number

Count how many defined values are in the array.

Kind: instance property of ArrayList
Returns: Number - Array elements that aren't undefined.

arrayList.pullExists() ⇒ Mixed

Get and remove the first existing value in the array.

Kind: instance method of ArrayList
Returns: Mixed - Existing value.

arrayList.push(item)

Add an item to the array. Either lengthens array, or uses an "empty" index.

Kind: instance method of ArrayList

| Param | Type | Description | | --- | --- | --- | | item | * | The item to add to the array. |

arrayList.add(array)

Add an array to the array. Either lengthens array or adds elements in "empty" indices.

Kind: instance method of ArrayList

| Param | Type | Description | | --- | --- | --- | | array | Array | Array to add. |

arrayList.remove(fn)

Removes elements from the array matching the fn (returns true).

Kind: instance method of ArrayList

| Param | Type | Description | | --- | --- | --- | | fn | function | Matcher to remove elements. |

arrayList.clear()

Sets all current elements in array to undefined.

Kind: instance method of ArrayList

BSP

BSP

Kind: global class

new BSP(height, width)

constructor

| Param | Type | | --- | --- | | height | Number | | width | Number |

bsP.makeNode(x, y, w, h, l, r) ⇒ Node

Create a node to put into the BSP.

Kind: instance method of BSP

| Param | Type | Description | | --- | --- | --- | | x | Number | X position of node. | | y | Number | Y position of node. | | w | Number | Width of node. | | h | Number | Height of node. | | l | Node | The left child of this node. | | r | Node | The right child of this node. |

bsP.makeTree(node, level)

Create a tree.

Kind: instance method of BSP

| Param | Type | Default | Description | | --- | --- | --- | --- | | node | Node | | The node to generate the tree starting at. | | level | Number | 0 | The current depth of the generation. |

bsP.split(node)

Split the given node into two child nodes.

Kind: instance method of BSP

| Param | Type | Description | | --- | --- | --- | | node | Node | The node to split. |

bsP.traverseInOrder(cb)

Traverse the tree in order.

Kind: instance method of BSP

| Param | Type | Description | | --- | --- | --- | | cb | function | Function to call per node. |

bsP.traversePreOrder(cb)

Traverse the tree pre order.

Kind: instance method of BSP

| Param | Type | Description | | --- | --- | --- | | cb | function | Function to call per node. |

bsP.traversePostOrder(cb)

Traverse the tree post order.

Kind: instance method of BSP

| Param | Type | Description | | --- | --- | --- | | cb | function | Function to call per node. |

Graph

A graph data structure. Undirected and using an adjacency list.

Kind: global class

new Graph()

constructor

graph.addVertex(v) ⇒ *

Add a vertex to the graph. If it already exists, it does nothing.

Kind: instance method of Graph
Returns: * - The added vertex.

| Param | Type | Description | | --- | --- | --- | | v | * | The vertex to add to the graph. |

graph.addEdge(src, dest)

Add an edge between src and dest.

Kind: instance method of Graph

| Param | Type | Description | | --- | --- | --- | | src | * | The source node. | | dest | * | The destination node. |

graph.getNeighbors(v) ⇒ Array

Get the neighbors of the given node.

Kind: instance method of Graph
Returns: Array - The array of neighbor nodes.

| Param | Type | Description | | --- | --- | --- | | v | * | The node to get neighbors for. |

graph.getWeightedNeighbors(v) ⇒ Array

Get the neighbor and wieights of the given node.

Kind: instance method of Graph
Returns: Array - The array of neighbor nodes.

| Param | Type | Description | | --- | --- | --- | | v | * | The node to get neighbors for. |

graph.bfs(startingNode, cb)

A breath first search through the graph, starting at the given node.

Kind: instance method of Graph

| Param | Type | Description | | --- | --- | --- | | startingNode | * | The node to start the search at. | | cb | function | A callback for each node in the search. |

graph.dfs(startingNode, cb)

A depth first search through the graph.

Kind: instance method of Graph

| Param | Type | Description | | --- | --- | --- | | startingNode | * | The node to start at. | | cb | function | A callback for each node in the search. |

graph.print()

For debugging, prints adjacency list.

Kind: instance method of Graph

Heap

A heap implemenation.

Kind: global class

new Heap(compare)

constructor

| Param | Type | | --- | --- | | compare | function |

heap.push(n)

Push an element onto the heap.

Kind: instance method of Heap

| Param | Type | Description | | --- | --- | --- | | n | * | The element to push onto the heap. |

heap.pop() ⇒ *

Remove and return the ximum element in the heap.

Kind: instance method of Heap
Returns: * - The ximum element on the heap.