Library for easy work with Two-Dimensional Arrays
import { Matrix } from "useful-matrix"
// for now (v1.0.8) only esm available
const matrixFrom2dArray = new Matrix([
[1, 2, 3, 4],
[1, 2, 3, 4],
[1, 2, 3, 4],
[1, 2, 3, 4]
])
const matrixFromOptions = new Matrix({
width: 4,
height: 4
}) // returns new Matrix([
// [0, 0, 0, 0],
// [0, 0, 0, 0],
// [0, 0, 0, 0],
// [0, 0, 0, 0]
// ])
- validX
- validY
- validPos
- validMatrixSource
- validRow
- validCol
- randomX
- randomY
- randomPos
- get
- getAllCols
- getRow
- getCol
- getItem
- getAllItems
- getFirstRow
- getFirstCol
- getFirstItem
- getLastRow
- getLastCol
- getLastItem
- set
- setAllCols
- setRow
- setCol
- setItem
- swapRows
- swapCols
- swapItems
- reverseX
- reverseY
- reverseXY
- rotateLeft
- rotateRight
- fillAll
- mapItems