MCPcopy Create free account
hub / github.com/MultithreadedJSBook/code-samples / constructor

Method constructor

ch5-game-of-life/gol.js:2–9  ·  view source on GitHub ↗
(size, buffer, paint = () => {})

Source from the content-addressed store, hash-verified

1class Grid {
2 constructor(size, buffer, paint = () => {}) {
3 const sizeSquared = size * size;
4 this.buffer = buffer;
5 this.size = size;
6 this.cells = new Uint8Array(this.buffer, 0, sizeSquared);
7 this.nextCells = new Uint8Array(this.buffer, sizeSquared, sizeSquared);
8 this.paint = paint;
9 }
10
11 getCell(x, y) {
12 const size = this.size;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected