Catalog npm
Back to packageRELEASE DETAILS

1.0.2

npm

2d-grid-neighbors

A library to get the values of neighbors of a grid as represented in a 2D array

Published22 Oct 2024
Direct dependencies4
Transitive dependenciesNot calculated

README

Current package documentation

Grid neighbor finder

Library returns the neighbors of a grid represented as a 2D array without wrapping.

Installing

npm i 2d-grid-neighbors

Usage

Getting the values of the neighbors:

const grid = [
    'a', 'b', 'c', 'd',
    'd', 'e', 'f', 'g',
    'h', 'i', 'j', 'k',
    'l', 'm', 'n', '0',
];

const getNeighborsForIndex = 5;
const result = getNeighbors(grid, getNeighborsForIndex);

// result: ['a', 'b', 'c', 'd', 'f', 'h', 'i', 'j']

If you need the indices, use getNeighborIndices().

This library works for a grid of any size provided that the grid has an equal number of columns and rows.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 4

Native requirements
4 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@babel/preset-typescript
Environment
{
  "local_name": "@babel/preset-typescript",
  "alias": false,
  "peer_metadata": null
}
^7.25.7development
@jest/globals
Environment
{
  "local_name": "@jest/globals",
  "alias": false,
  "peer_metadata": null
}
^29.7.0development
ts-jest
Environment
{
  "local_name": "ts-jest",
  "alias": false,
  "peer_metadata": null
}
^29.2.5development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5.6.3development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-zs14XANPDGtFsQaEAtcTPhC+ibWMpKVm1n1DqD7K3igzt/QUYJpa0iRKLH6sX68NmbWbghKP/eo+UsctbgMC4A==",
  "shasum": "a8c9ff0f3c7dbaa09e869c1ea873d8b3e9d71757",
  "tarball": "https://registry.npmjs.org/2d-grid-neighbors/-/2d-grid-neighbors-1.0.2.tgz",
  "fileCount": 14,
  "unpackedSize": 13682,
  "signatures": [
    {
      "keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
      "sig": "MEYCIQCAOurJoc7UTOrkqG5NSbcPhBNW+5QKcKJl764gUtNBngIhAKs+XKDTO+2vnzPIYpo7ccVz2kHCIt1HVgoJuWwLADvC"
    }
  ]
}

Repository

PENDING
alexanderschaller/2d-array-neighbors

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:10 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:d1d8eb79663cea36f956523973ece2d827ba71e8bf9f763e7b580a3bcff50c06

Other collected versions

1.0.122 Oct1.0.022 OctView all collected versions →