# @mightyplow/matrix

> A class which helps handling 2-dimensional arrays.

Latest version **1.1.0** (published 2021-01-01) · ISC license · 0 weekly downloads

## Install

```sh
npm install @mightyplow/matrix
pnpm add @mightyplow/matrix
yarn add @mightyplow/matrix
bun add @mightyplow/matrix
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-01-01 |
| First published | 2020-12-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=5 |
| Dependencies | 0 |
| Unpacked size | 21.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | mightyplow |
| Maintainers | mightyplow |
| Keywords | matrix, util, arrays |

## Links

- npm: https://www.npmjs.com/package/@mightyplow/matrix
- npm.io page: https://npm.io/package/@mightyplow/matrix

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2021-01-01
- 1.0.0 — 2020-12-31

## README

<a id="module_@mightyplow/matrix"></a>

## @mightyplow/matrix
This class helps handling 2-dimensional arrays (=> a matrix). It provides methods
to retrieve data about the matrix as well as manipulating the matrix data.

The module can be used with node directly and with bundlers. For bundlers it ships with
minified ES5 compatible code. For node it is transpiled for compatibility with version
5 and above.

## Installation
```
npm install -P @mightyplow/matrix
```

<a id="Matrix"></a>

## Matrix

* [Matrix](#Matrix)
    * [new Matrix(initialData)](#new_Matrix_new)
    * [.numCols](#Matrix+numCols) : <code>int</code>
    * [.numRows](#Matrix+numRows) : <code>int</code>
    * [.getData()](#Matrix+getData) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
    * [.setData([data])](#Matrix+setData) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
    * [.clear()](#Matrix+clear) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
    * [.getRow(rowNum)](#Matrix+getRow) ⇒ <code>Array.&lt;any&gt;</code>
    * [.getRows([length], [startRow])](#Matrix+getRows) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
    * [.insertRows([rows], [startRow])](#Matrix+insertRows) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
    * [.deleteRows(startRow, [length])](#Matrix+deleteRows) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
    * [.getCol(colNum)](#Matrix+getCol) ⇒ <code>Array.&lt;any&gt;</code>
    * [.getCols([length], [startCol])](#Matrix+getCols) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
    * [.insertCols([cols], [startCol])](#Matrix+insertCols) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
    * [.deleteCols(startCol, [length])](#Matrix+deleteCols) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
    * [.rotateCw()](#Matrix+rotateCw) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
    * [.rotateCcw()](#Matrix+rotateCcw) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
    * [.flipH()](#Matrix+flipH) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
    * [.flipV()](#Matrix+flipV) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>

<a id="new_Matrix_new"></a>

### new Matrix(initialData)
Creates an instance of the Matrix class. This constructor function can be used with and without the new keyword.


| Param | Type |
| --- | --- |
| initialData | <code>Array.&lt;Array.&lt;any&gt;&gt;</code> | 

<a id="Matrix+numCols"></a>

### matrix.numCols : <code>int</code>
Returns the number of columns.

<a id="Matrix+numRows"></a>

### matrix.numRows : <code>int</code>
Returns the number of rows.

<a id="Matrix+getData"></a>

### matrix.getData() ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
Returns the 2-dimensional array.

<a id="Matrix+setData"></a>

### matrix.setData([data]) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
Sets the 2-dimensional array.


| Param | Type | Default |
| --- | --- | --- |
| [data] | <code>Array.&lt;Array.&lt;any&gt;&gt;</code> | <code>[]</code> | 

<a id="Matrix+clear"></a>

### matrix.clear() ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
Removes all data in matrix and leaves behind an empty array.

<a id="Matrix+getRow"></a>

### matrix.getRow(rowNum) ⇒ <code>Array.&lt;any&gt;</code>
Returns a single specific row of the matrix. When passing a negative number, it is counted from the end.

**Throws**:

- <code>Error</code> 


| Param | Type |
| --- | --- |
| rowNum | <code>int</code> | 

<a id="Matrix+getRows"></a>

### matrix.getRows([length], [startRow]) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
Returns multiple specific rows of the matrix.


| Param | Type | Default |
| --- | --- | --- |
| [length] | <code>int</code> | <code>this.numRows</code> | 
| [startRow] | <code>int</code> | <code>0</code> | 

<a id="Matrix+insertRows"></a>

### matrix.insertRows([rows], [startRow]) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
Insert multiple rows at a given point in the matrix.


| Param | Type | Default |
| --- | --- | --- |
| [rows] | <code>Array.&lt;any&gt;</code> | <code>[]</code> | 
| [startRow] | <code>int</code> | <code>this.numRows</code> | 

<a id="Matrix+deleteRows"></a>

### matrix.deleteRows(startRow, [length]) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
Deletes multiple rows at a given point in the matrix and returns the deleted rows.

**Returns**: <code>Array.&lt;Array.&lt;any&gt;&gt;</code> - deleted rows  
**Throws**:

- <code>Error</code> 


| Param | Type | Default |
| --- | --- | --- |
| startRow | <code>int</code> |  | 
| [length] | <code>int</code> | <code>1</code> | 

<a id="Matrix+getCol"></a>

### matrix.getCol(colNum) ⇒ <code>Array.&lt;any&gt;</code>
Returns a single specific column of the matrix. When passing a negative number, it is counted from the end.

**Throws**:

- <code>Error</code> 


| Param | Type |
| --- | --- |
| colNum | <code>int</code> | 

<a id="Matrix+getCols"></a>

### matrix.getCols([length], [startCol]) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
Returns multiple specific columns of the matrix.


| Param | Type | Default |
| --- | --- | --- |
| [length] | <code>int</code> | <code>this.numCols</code> | 
| [startCol] | <code>int</code> | <code>0</code> | 

<a id="Matrix+insertCols"></a>

### matrix.insertCols([cols], [startCol]) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
Insert multiple columns at a given point in the matrix.


| Param | Type | Default |
| --- | --- | --- |
| [cols] | <code>Array.&lt;any&gt;</code> | <code>[]</code> | 
| [startCol] | <code>int</code> | <code>this.numRows</code> | 

<a id="Matrix+deleteCols"></a>

### matrix.deleteCols(startCol, [length]) ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
Deletes multiple columns at a given point in the matrix and returns the deleted rows.

**Returns**: <code>Array.&lt;Array.&lt;any&gt;&gt;</code> - deleted rows  
**Throws**:

- <code>Error</code> 


| Param | Type | Default |
| --- | --- | --- |
| startCol | <code>int</code> |  | 
| [length] | <code>int</code> | <code>1</code> | 

<a id="Matrix+rotateCw"></a>

### matrix.rotateCw() ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
Rotates the matrix clockwise.

<a id="Matrix+rotateCcw"></a>

### matrix.rotateCcw() ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
Rotates the matrix counter clockwise.

<a id="Matrix+flipH"></a>

### matrix.flipH() ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
Flips the matrix horizontally.

<a id="Matrix+flipV"></a>

### matrix.flipV() ⇒ <code>Array.&lt;Array.&lt;any&gt;&gt;</code>
Flips the matrix vertically.

---
_Source: https://npm.io/package/@mightyplow/matrix · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
