modules/index.js
function(x, y, dir) {
            if(!this.isCell(x, y)) { return null; }
            // dir must be string and in dirmap
            if(!this.isDir(dir)) { return null; }
            let _DX = { "E": 1, "W": -1, "N": 0, "S": 0 };
            let _DY = { "E": 0, "W": 0, "N": -1, "S": 1 };
            var nx = x + _DX[dir];
            var ny = y + _DY[dir];
            if(!this.isCell(nx, ny)) { 
                return null; 
            }
            return { x: nx, y: ny };
        }
function(x, y, dir) {
            if(!this.isCell(x, y)) { return null; }
            // dir must be string and in dirmap
            if(!this.isDir(dir)) { return null; }
            let _DX = { "E": 1, "W": -1, "N": 0, "S": 0 };
            let _DY = { "E": 0, "W": 0, "N": -1, "S": 1 };
            var nx = x + _DX[dir];
            var ny = y + _DY[dir];
            if(!this.isCell(nx, ny)) { 
                return null; 
            }
            return { x: nx, y: ny };
        }
function ( x , y , dir ) { if ( ! this . isCell ( x , y ) ) { return null ; } // dir must be string and in dirmap if ( ! this . isDir ( dir ) ) { return null ; } let _DX = { "E" : 1 , "W" : - 1 , "N" : 0 , "S" : 0 } ; let _DY = { "E" : 0 , "W" : 0 , "N" : - 1 , "S" : 1 } ; var nx = x + _DX [ dir ] ; var ny = y + _DY [ dir ] ; if ( ! this . isCell ( nx , ny ) ) { return null ; } return { x : nx , y : ny } ; }
Returns neighbor for direction
@param {string} dir A string representing a direction
@function
@instance
@memberof module:connection-grid-square
@returns {string}
@example <caption>usage</caption>
var cell = grid.getNeighbor(1,1,"S");
Returns neighbor for direction