GRID
Simple grid data structure.
Install
npm install grid-data
Usage
// create a empty 2x2 gridconst g = 2 2 // set valuesg // zero-based indexg // get valuesconsole // => "first cell"console // => "last cell" // check a positionconsole // => false // create a 2x2 grid from a Arrayconst ga = Grid console // => 1console // => 2console // => 3console // => 4 // export the grid as Arrayconsole; // => [1,2,3,4] // export the grid as Stringconsole; // => 1,2,3,4 // use forEach to interactga // sanitizes a X position with .clipX (or use .clipY for Y positions)console // => 1console // => 0 // clone a gridconst cloned = ga // clear all stored valuesgaclear // public propertiesgwidthgheightglength // === g.width * g.height
License
MIT