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

@wonderlandlabs/multidim

v1.0.1

Published

A multidimensional grid

Downloads

3

Readme

This is a utility class that expresses n-dimensional integral matricies allowing you to encode an N-dimensional cooridate into a value with a single flattened integer.

Assumptions:

  • there are one or more dimensions with a min(imum) and max(imum) integral value. Each has a string name.
  • each dimension is at least two integers; i.e., max > min.
  • values in that dimension can be from the minimum value (inclusive) up to the maximum value (inclusive).

Creating a grid

Grids are crated by instantiating the grid class:


const g = new Grid(
  {min :-10, max: 10, name: 'x'},
  {min: 5, max: 10, name: 'y'}
);

Grid stores everything based on the reduction of a coordinate to an index. This makes storing key-value pairs for the grids' content in arrays/Maps.

There are two types of storage:

  • sparse data (data with a lot of missing values) are stored in Maps.
  • dense data (data with mostly or completely filled-out grids) are stored in arrays.

In both cases the data is stored as an indexed value. There is no assumptions about what is stored in a grid.

API

constructor(dim, dim, dim)

defines the dimensions of the array. Dimensions can be defined using various notation:

min-max

{name: 'x', min: 0, max: 20}

radius

{name: 'y', radius: 5}
// === {name: 'y', min: -5, max: 5}

size

{name: 'y', size: 5}
// === {name: 'y', min: 0, max: 5}

get(point); get(index)

returns the value stored for a given coordinate or index.

set(point, value)

sets the value stored at a given coordinate value or index.

storage

'sparse' or 'dense'. Setting this value defines the storage system for data AND erases any stored data.

store (read only)

a map or array; the currently stored data.

seedFunction

a property that if set, returns a value for any unset point. That value is stored before returned from get(), but is used lazily; that is, setting the seed function doesn't change anything in storage until get(point) is called, and changing the seed function won't update any previously retrieved values.

near(point, ortho = false)

returns all the points within +/- 1 of the given point. if ortho(gonal) is true, returns coordinates that are only adjacent by one dimension from the given point. otherwise includes diagonals.

ortho returns 2 * (number of dimensions) points.

non-ortho returns 3 ** (number of dimensions) points.

note - the return value is a set of points that is NOT filtered by containment in the grid.

Branches

Branches is a fun utility class that uses a 2d grid to draw a maze. useful for fucking over your D & D group:

https://codesandbox.io/s/mazing-qsqf8

maze

Trust Jebus

This is a very alpha, speed oriented module. As such, there is not a lot of data validation and type-checking.