0.2.1 • Published 4 years ago
find-neighbors-in-matrix v0.2.1
Find-neighbors-in-matrix
Easy-to-use, typed, and tested utility to find the neighbors of a cell in a matrix.
Install
yarn add -E find-neighbors-in-matrix # or npm install find-neighbors-in-matrixUse
import { findNeighborsInMatrix } from 'find-neighbors-in-matrix'
const matrix = [
[1, 1, 1],
[1, 1, 1],
[1, 1, 1],
]
const cell = [0, 0] // x, y
const neighbors = findNeighborsInMatrix({ cell, matrix }) // [[1, 0], [1, 1], [0, 1]]Contribute
The library leverages TSDX as a boilerplate.
To run the library, use:
yarn start # or npm run startThis command builds to /dist and runs the project in watch mode, so any edits you save inside src causes a rebuild to /dist.
To do a one-off build, use:
yarn build # or npm run buildJest tests are set up to run with:
yarn test # or npm run testConfiguration
Code quality is set up with prettier, husky, and lint-staged.
Bundle Analysis
size-limit is set up to calculate the real cost of the library with:
yarn size # or npm run sizeRollup
The library uses Rollup as a bundler and generates multiple rollup configs for various module formats and build settings.
Module Formats
CJS, ESModules, and UMD module formats are supported.