
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
GridsJS is an easy and intuitive JavaScript library for creating, manipulating, and rendering 2D grids. Perfect for games, simulations, and any grid-based applications, it handles all the math for you. made with <3 by me!
Create grid-based systems with ease!
GridsJS saves you time by giving you a simple, intuitive way to work with 2D grids. It’s versatile enough to build games, simulations, or any grid-based system you can imagine.
Install via npm:
npm install gridsjs
And then in your JS file:
const grids = require('gridsjs');
// Initialize a 10x10 grid
grids.initGrid(10, 10);
x = widthy = height// Set a value at x=3, y=5
grids.SetGridValue(3, 5, 1);
// Get a value at x=3, y=5
const value = grids.GetGridValue(3, 5);
console.log(value); // 1
// Fill the entire grid with 0s
grids.FillAllGrids(0);
grids.RenderGrid();
Output will display the grid in the console with each cell’s value.
const grids = require('../index');
const WIDTH = 10;
const HEIGHT = 10;
// Initialize grid
grids.initGrid(WIDTH, HEIGHT);
// Randomly populate grid (30% chance alive)
for (let y = 0; y < HEIGHT; y++) {
for (let x = 0; x < WIDTH; x++) {
grids.SetGridValue(x, y, Math.random() < 0.3 ? 1 : 0);
}
}
// Render function
function RenderGridCustom() {
let output = '';
for (let y = 0; y < HEIGHT; y++) {
for (let x = 0; x < WIDTH; x++) {
output += grids.GetGridValue(x, y) === 1 ? 'O ' : '. ';
}
output += '\n';
}
console.clear();
console.log(output);
}
// Count alive neighbors
function countAliveNeighbors(x, y) {
let count = 0;
for (let dy = -1; dy <= 1; dy++) {
for (let dx = -1; dx <= 1; dx++) {
if (dx === 0 && dy === 0) continue;
const nx = x + dx;
const ny = y + dy;
if (nx >= 0 && nx < WIDTH && ny >= 0 && ny < HEIGHT) {
count += grids.GetGridValue(nx, ny);
}
}
}
return count;
}
// Next generation
function nextGeneration() {
const newGrid = [];
for (let y = 0; y < HEIGHT; y++) {
for (let x = 0; x < WIDTH; x++) {
const alive = grids.GetGridValue(x, y);
const neighbors = countAliveNeighbors(x, y);
let newState = alive;
if (alive === 1 && (neighbors < 2 || neighbors > 3)) newState = 0;
if (alive === 0 && neighbors === 3) newState = 1;
newGrid.push(newState);
}
}
for (let i = 0; i < newGrid.length; i++) grids.SetRawGridValue(i, newGrid[i]);
}
// Animation loop: 1 second per generation
setInterval(() => {
RenderGridCustom();
nextGeneration();
}, 1000);
You can then build animations, simulations, or any grid-based logic using the simple API provided.
initGrid(width, height) – initialize a gridSetGridValue(x, y, value) – set a cell valueGetGridValue(x, y) – get a cell valueSetRawGridValue(index, value) – set cell by raw indexGetRawGridValue(index) – get cell by raw indexFillAllGrids(value) – fill entire gridRenderGrid() – print the grid to consoleFeel free to open issues or submit pull requests. Everyone is welcome!
MIT
FAQs
GridsJS is an easy and intuitive JavaScript library for creating, manipulating, and rendering 2D grids. Perfect for games, simulations, and any grid-based applications, it handles all the math for you. made with <3 by me!
We found that gridsjs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.