strict-matrix
v1.0.2
Published
Limited 2 dimensional arrays
Downloads
2
Maintainers
Readme
strict-matrix
A module that provides simple 2 dimensional arrays.
npm install strict-matrix
How to use
const StrictMatrix = require('strict-matrix');
let mat = new StrictMatrix(4, 4, 'def'); // sizeX, sizeY, defaultValue (can take a function, it will execute it, the function gets passed with x and y of the construction)
// It fills with null if no defaultValue provided
mat.set(2, 2, 'value 1 at 2,2'); // Takes x, y, value
mat.set(4, 5, 'hey'); // Matrix out of bounds
mat.get(2, 2); // Takes x, y, in this case outputs "value 1 at 2,2"
mat.get(4, 5); // Matrix out of bounds
mat.getArray(); // Get the array of array equivalent of the matrix
License
MIT (SEE LICENSE FILE)