Current collected state Current
Observed since 20 Oct, 19:10 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
2d-grid-neighbors
A library to get the values of neighbors of a grid as represented in a 2D array
Library returns the neighbors of a grid represented as a 2D array without wrapping.
npm i 2d-grid-neighbors
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.
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
@babel/preset-typescriptEnvironment{
"local_name": "@babel/preset-typescript",
"alias": false,
"peer_metadata": null
} | ^7.25.7 | development |
@jest/globalsEnvironment{
"local_name": "@jest/globals",
"alias": false,
"peer_metadata": null
} | ^29.7.0 | development |
ts-jestEnvironment{
"local_name": "ts-jest",
"alias": false,
"peer_metadata": null
} | ^29.2.5 | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^5.6.3 | development |
Source distribution
{
"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"
}
]
}Shared repository data · GitHub
Observed since 20 Oct, 19:10 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:d1d8eb79663cea36f956523973ece2d827ba71e8bf9f763e7b580a3bcff50c06