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

@mitchallen/connection-grid

v0.1.34

Published

map connections between cells in a 2D grid

Downloads

15

Readme

@mitchallen/connection-grid

Map connections between cells in a 2D grid.


Installation

You must use npm 2.7.0 or higher because of the scoped package name.

$ npm init
$ npm install @mitchallen/connection-grid --save

Usage

"use strict";
    
let gridFactory = require("@mitchallen/connection-grid");
    
let xSize = 5;
let ySize = 6;

let grid = gridFactory.Square({ x: xSize, y: ySize });

Browser Usage:

You can reference a minimized client version inside an HTML script tag using one of these URL's:

Example:

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8">
        <title>Connection-Grid Example</title>
        <meta name="description" content="Connection Grid Example">
        <script src="https://unpkg.com/@mitchallen/[email protected]/dist/connection-grid.min.js"></script>
        <script>
          var factory = window.MitchAllen.ConnectionGrid;
          console.log(factory);
          var xSize = 10, ySize = 5;
          var sg = factory.Square( { x: xSize, y: ySize } );
          sg.log(); 
        </script>
      </head>
      <body>
        <h1>Connection Grid Example</h1>
      </body>
    </html>

Testing

To test, go to the root folder and type (sans $):

$ npm test

Run all tests using nodemon:

$ npm run test-nodemon

Run suites using nodemon:

$ npm run test-square
$ npm run test-hexagon
$ npm run test-triangle
$ npm run test-circle

Repo(s)


Contributing

In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.


Version History

Version 0.1.28

  • replaced modules/square.js with @mitchallen/connection-grid-square

Version 0.1.27

  • square now uses @mitchallen/grid-square

Version 0.1.26

  • Replaced modules/base.js with @mitchallen/connection-grid-core

Version 0.1.25

  • Browser now must use window.MitchAllen.ConnectionGrid.

Version 0.1.24

  • Updated CDN URL

Version 0.1.23

  • Added client example

Version 0.1.22

  • Changed client window name to 'ConnectionGrid'

Version 0.1.21

  • Added client distribution

Version 0.1.20

  • updated to latest grid

Version 0.1.19

  • Updated documentation for connection directions
  • Removed unused code

Version 0.1.18

  • Refactored Circle.getNeighbor
  • Fixed bug in Circle.getNeighbor

Version 0.1.17

  • Add connectsAny method

Version 0.1.16

  • Cirlce.getNeighbor with CW for last cell in ring now wraps properly

Version 0.1.15

  • Added Triangle method

Version 0.1.14

  • Fixed bug in isDir
  • Fixed Circle direction mapp

Version 0.1.13

  • Refactored code base and tests

Version 0.1.12

  • Added tests for Circle

Version 0.1.11

  • Added Hexagon and Circle methods

Version 0.1.10

  • now uses @mitchallen/grid 0.1.10

Version 0.1.9

  • now uses @mitchallen/grid 0.1.9
  • changed internal use of grid.create to grid.Square
  • added Square method to replace create method
  • added test suites for Square method
  • create method now generates deprecation warning

Version 0.1.8

  • now uses @mitchallen/grid 0.1.8
  • added experimental Hexagon method

Version 0.1.7

  • now uses @mitchallen/grid 0.1.7
  • x and y values that are missing or less than 0 will be normalized to 0
  • updated tests

Version 0.1.6

  • added replaced getDirMap function with dirMap property

Version 0.1.5

  • added getOppositeDir method

Version 0.1.5

  • added getOppositeDir method

Version 0.1.4

  • added mask and isMasked methods

Version 0.1.3

  • now uses @mitchallen/grid 0.1.6

Version 0.1.2

  • added connects method

Version 0.1.1

  • fixed bug in hasConnections

Version 0.1.0

  • initial release