node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »

@mitchallen/connection-grid-square

@mitchallen/connection-grid-square

Connection grid for square array

Version Coverage Status Version


Installation

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

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

Usage

"use strict";

var gridFactory = require("@mitchallen/connection-grid-square");

let xSize = 5;
let ySize = 6;

var grid = gridFactory.create({ x: xSize, y: ySize });

Browser Usage:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Connection-Grid-Square Example</title>
    <meta name="description" content="Connection Grid Square Example">
    <!-- either cdn should work -->
    <!--
    <script src="https://cdn.rawgit.com/mitchallen/connection-grid-square/v0.1.9/dist/connection-grid-square.min.js"></script>
    -->
    <script src="https://unpkg.com/@mitchallen/connection-grid-square@0.1.9/dist/connection-grid-square.min.js"></script>
    <script>
      var factory = window.MitchAllen.ConnectionGridSquare;
      console.log(factory);
      var xSize = 10, ySize = 5;
      var sg = factory.create( { x: xSize, y: ySize } );
      console.log(sg);
      sg.log(); 
    </script>
  </head>
  <body>
    <h1>Connection Grid Square Example</h1>
  </body>
</html>

Modules

connection-grid-square@mitchallen/connection-grid-core

Connection Grid Square generated by create

connection-grid-square-factory

A factory for generating connection grid square objects

External

@mitchallen/connection-grid-core

Connection Grid Core

connection-grid-square ⇐ @mitchallen/connection-grid-core

Connection Grid Square generated by create

Extends: @mitchallen/connection-grid-core

connection-grid-square.getNeighbor(dir) ⇒ string

Returns neighbor for direction

Kind: instance method of connection-grid-square

Param Type Description
dir string A string representing a direction

Example (usage)

var cell = grid.getNeighbor(1,1,"S"); 

connection-grid-square.getNeighborDirs(x, y) ⇒ array

Returns an array of neighbors for the cell at x,y

Kind: instance method of connection-grid-square

Param Type Description
x number X coordinate of cell
y number Y coordinate of cell

Example (usage)

var list = grid.getNeighborDirs(1,1); 

connection-grid-square-factory

A factory for generating connection grid square objects

connection-grid-square-factory.create(options) ⇒ connection-grid-square

Factory method that returns a connection grid square object. It takes one spec parameter that must be an object with named parameters.

Kind: static method of connection-grid-square-factory

Param Type Description
options Object Named parameters for generating a connection grid square
options.x number The size along the x axis
options.y number The size along the y axis

Example (Creating a connection-grid-square)

"use strict";
var gridFactory = require("@mitchallen/connection-grid-square");
let xSize = 5;
let ySize = 6;
var grid = gridFactory.create({ x: xSize, y: ySize });

@mitchallen/connection-grid-core

Connection Grid Core

Kind: global external
See: @mitchallen/connection-grid-core


Testing

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

$ npm test

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.9

  • updated .npmignore
  • updated dependencies

Version 0.1.8

  • updated to latest version of grid-square and connection-grid-core
  • updated test coverage to 100%

Version 0.1.7

  • integrated travis-ci and codecov.io

Version 0.1.6

  • installed latest version of @mitchallen/connection-grid-core

Version 0.1.5

  • installed latest version of @mitchallen/connection-grid-core
  • refactored documentation

Version 0.1.4

  • corrected version history

Version 0.1.3

  • installed latest version of @mitchallen/connection-grid-core
  • updated npm scripts
  • updated client example
  • integrated jsdoc

Version 0.1.2

  • error while publishing, trying again

Version 0.1.1

  • added missing package dependency for @mitchallen/connection-grid-core

Version 0.1.0

  • initial release