# array-grid

> Two-dimensional implementation of ndarray to avoid dynamic code generation eval.

Latest version **1.5.0** (published 2015-11-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install array-grid
pnpm add array-grid
yarn add array-grid
bun add array-grid
```

## 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.5.0 |
| Published | 2015-11-14 |
| First published | 2014-08-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Matt McKegg |
| Maintainers | mmckegg |
| Keywords | 2d, array, ndarray, grid, xy, two, dimensions |

## Links

- npm: https://www.npmjs.com/package/array-grid
- Repository: https://github.com/mmckegg/array-grid
- Issues: https://github.com/mmckegg/array-grid/issues
- npm.io page: https://npm.io/package/array-grid

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.5.0 (latest) — 2015-11-14
- 1.4.0 — 2014-10-19
- 1.3.0 — 2014-08-09
- 1.2.0 — 2014-08-08
- 1.1.1 — 2014-08-06
- 1.1.0 — 2014-08-03
- 1.0.0 — 2014-08-01

## README

array-grid
===

Two-dimensional implementation of ndarray with coordinate lookup and sub-array placement.

This modules conforms to the same API as [ndarray](https://github.com/mikolalysenko/ndarray) except fixed at 2-dimensions with a couple of other useful methods (`lookup` and `place`). Use if you need to avoid the runtime eval code generation of ndarray (e.g. Chrome Packaged App).

## Install via [npm](https://npmjs.org/package/array-grid)

```bash
$ npm install array-grid
```

## API

```js
var ArrayGrid = require('array-grid')
var array = ArrayGrid([1,2,3,4], [2, 2])
```

### `ArrayGrid(data[, shape, stride, offset])`

- `data` is a 1D array storage. It is either an instance of Array or a typed array.
- `shape` is the shape of the view (Default: `[data.length, 1]`)
- `stride` is the resulting stride of the new array. (Default: row major `[shape[1], 1]`)
- `offset` is the offset to start the view (Default: 0)

Returns a 2-dimensional array view of the underlying data.

### `array.get(row, col)`

Get the value at the position specified.

### `array.set(row, col, value)`

Set the value of the position specified.

### `array.index(row, col)`

Get the interal 1d `data` index of the specified coordinates.

### `array.lookup(value)`

Lookup the `[row,col]` coordinates of the specified `value`.

### `array.coordsAt(index)`

Lookup the `[row,col]` coordinates of the specified `index`.

### `array.place(originRow, originCol, array)`

Stamp another ArrayGrid or two-dimensional ndarray starting at the origin specified.

### `array.getRange(shape, offsetCoords)`

Copy the specified range starting at `offsetCoords` and return a new ArrayGrid.

### `array.data` (attribute)

The underlying one-dimensional array holding the data.

### `array.shape` (attribute)

`[rows,columns]` of the grid.

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