useful-matrix
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

useful-matrix v1.0.8

Library for easy work with Two-Dimensional Arrays

NPM Version

Usage

Creating new matrix

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]
// ])

Now (v1.0.8) available this methods

  • 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

full documentation will soon appear on the website

Package Sidebar

Install

npm i useful-matrix

Weekly Downloads

2

Version

1.0.8

License

ISC

Unpacked Size

12.4 kB

Total Files

4

Last publish

Collaborators

  • shark1_11