# observ-grid

> An observable array-grid.

Latest version **2.10.1** (published 2015-05-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install observ-grid
pnpm add observ-grid
yarn add observ-grid
bun add observ-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 | 2.10.1 |
| Published | 2015-05-21 |
| First published | 2014-08-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Matt McKegg |
| Maintainers | mmckegg |
| Keywords | grid, observ, array, ndarray |

## Links

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

## Dependencies (4)

- [adiff](https://npm.io/package/adiff.md) ^0.2.12
- [observ](https://npm.io/package/observ.md) ^0.2.0
- [array-grid](https://npm.io/package/array-grid.md) ^1.4.0
- [observ-array](https://npm.io/package/observ-array.md) ^3.2.1

## 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

- 2.10.1 (latest) — 2015-05-21
- 2.10.0 — 2015-05-21
- 2.9.0 — 2015-03-31
- 2.8.1 — 2014-12-22
- 2.8.0 — 2014-10-21
- 2.7.0 — 2014-10-21
- 2.6.0 — 2014-10-19
- 2.5.0 — 2014-10-19
- 2.4.0 — 2014-10-10
- 2.3.0 — 2014-08-21
- 2.2.0 — 2014-08-16
- 2.1.0 — 2014-08-12
- 2.0.0 — 2014-08-12
- 1.1.1 — 2014-08-10
- 1.1.0 — 2014-08-09
- … 1 more at https://npm.io/package/observ-grid/versions

## README

observ-grid
===

An observable array-grid.

Allows all the same operations as [array-grid](https://github.com/mmckegg/array-grid), but is [observable](https://github.com/raynos/observ-array).

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

```bash
$ npm install observ-grid
```

## API

```js
var ObservGrid = require('observ-grid')
```

### var grid = ObservGrid(data, shape[, stride])

- `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.

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

Get the value at the position specified.

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

Set the value of the position specified. Notifies all observers.

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

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

### `grid.lookup(value)`

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

### `grid.coordsAt(index)`

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

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

Stamp another ArrayGrid or two-dimensional ndarray starting at the origin specified. Batches changes then notifies all observers.

### `grid.transaction(func)`

Batch changes together. `func` will be called with a mutable ArrayGrid which can be modified. On return, the data will be diffed against original and merged into the `grid`. A single observ notification will be triggered.

## Observable Attributes

### `grid`

The grid itself is observable and will notify on all changes.

```js
var grid = ObservGrid([0,1,2,3,4,5], [2,3])
var removeListener = grid(function(value){
  // value is a new instance of ArrayGrid with the updated data
  console.log(value._diff) //= [ [0, 1, 'A'] ]
  console.log(value.get(0, 1)) //= 'A'
  console.log(value.data) //= ['A', 1, 2, 3, 4, 5]
})
grid.set(0, 1, 'A')

// clean up event handler
removeListener()
```

### `grid.data` ([ObservArray](https://github.com/raynos/observ-array))

The underlying one-dimensional array holding the data. This can be modified directly and observers will be notified.

### `grid.shape` (ObservArray)

`[rows,columns]` of the grid.

### `grid.stride` (ObservArray)

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