# @pomle/grid

> TypeScript Grid class for grids of any size and dimension.

Latest version **0.0.1-2** (published 2023-12-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @pomle/grid
pnpm add @pomle/grid
yarn add @pomle/grid
bun add @pomle/grid
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1-2 |
| Published | 2023-12-24 |
| First published | 2023-12-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 54.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Pontus Alexander |
| Maintainers | pomle |
| Keywords | grid |

## Links

- npm: https://www.npmjs.com/package/@pomle/grid
- Repository: https://github.com/pomle/grid
- Homepage: https://github.com/pomle/grid#readme
- Issues: https://github.com/pomle/grid/issues
- npm.io page: https://npm.io/package/@pomle/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

- 0.0.1-2 (latest) — 2023-12-24
- 0.0.1-1 — 2023-12-24
- 0.0.1-0 — 2023-12-23

## README

# Grid

A JavaScript and TypeScript lib for working with grids of any size and any dimension.

## Usage

### Write a number to each cell in a 2x2 grid

```ts
import { Grid } from '@pomle/grid';

const grid = new Grid<number, 'x' | 'y'>({ x: 2, y: 2 });

let count = 0;
for (const coord of grid) {
  count += 1;
  grid.set(coord, count);
}
```

### Dimensions can use any name

```ts
import { Grid } from '@pomle/grid';

const grid = new Grid({ width: 320, height: 240 });
```

### Dimensions can use number of dimensions

```ts
import { Grid } from '@pomle/grid';

const grid = new Grid({ a: 10, b: 10, c: 10, d: 10 });
grid.set({ a: 1, b: 1, c: 1, d: 1 }, 'one');
grid.set({ a: 2, b: 2, c: 2, d: 2 }, 'two');
```

### Neighbours can be explored

```ts
import { Grid } from '@pomle/grid';

const grid = new Grid({ x: 3, y: 3 });
for (const coord of grid.neighbours({ x: 1, y: 1 })) {
  console.log(coord); // Prints cartesian product of {x: 0, y: 0} to {x: 2, y: 2}
}
```

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