0.1.1 • Published 9 years ago
bearded-2d v0.1.1
#Bearded 2 Dimensional Arrays
If you can understand how to deal with it, it becomes just another data type
Installing:
$ yarn add bearded-2dAnd then somewhere in your code:
import Grid from 'bearded-2d'
const grid = new Grid([
[1,2,3],
[4,5,6],
[7,8,9]
])##API
| Method | Arguments | Returns |
|---|---|---|
| rows | null | two-dimensional array |
| columns | null | two-dimensional array |
| value | null | two-dimensional array |
| map | fn: Function | new Grid |
| contains | val: any | Boolean |
| locations | null | two-dimensional array |
| get | location: double/number | Array/any |
| set | location: double/number, value: any | undefined |
| block | start: double, width: number, height: number | two-dimensional array |
##Note on Set
Set will make grid.__value into a square regardless of the index given. For instance, if your grid is 3 by 3 and you grid.set([5,5],val), you will now have a 5 by 5 grid with [undefined,undefined,undefined,undefined, undefined, undefined] and your rows will be [1,2,3,undefined,undefined,undefined], i.e. It will create undefined rows and columns if you give it a bigger index than it can handle