function getKey({ x, y, type }) { const gridX = x - x % 5; const gridY = y - y % 5; return `${gridX}-${gridY}`; } export default function Grid() { this.points = {}; this.gridSize = 5; }; Grid.prototype.setPoint = function({ x, y, type }, detail) { this.points[getKey({ x, y, type })] = detail; }; Grid.prototype.getPoint = function({ x, y, type }) { return this.points[getKey({ x, y, type })]; } Grid.prototype.deletePoint = function({ x, y, type }) { delete this.points[getKey({ x, y, type })]; }; // Grid.prototype.setArea = function({ x, y, w, h, type }) { // for (let i = x; i <= (x + w); i += this.gridSize) { // for (let j = y; j <= (y + h); j += this.gridSize) { // this.setPoint({ x: i, y: j, type }); // } // } // }; // const Store = function(initialProps) { // this.state = Object.freeze(initialProps); // } // // Store.prototype.set = function(props) { // this.state = Object.freeze(Object.assign({}, this.state, props)); // return this.state; // }; // // Store.prototype.get = function() { // return this.state; // } // // export default Store;