New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pomle/grid

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pomle/grid

TypeScript Grid class for grids of any size and dimension.

  • 0.0.1-2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

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

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

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

Dimensions can use number of dimensions

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

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

Keywords

FAQs

Package last updated on 24 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc