🔨 fix typing

This commit is contained in:
platane
2020-10-14 22:37:27 +02:00
committed by Platane
parent 8f5c1969a6
commit 3d16c675bd
9 changed files with 44 additions and 46 deletions

View File

@@ -0,0 +1,13 @@
import { setColor, createEmptyGrid } from "@snk/compute/grid";
import type { Cell } from "@snk/github-user-contribution";
import type { Color } from "@snk/compute/grid";
export const userContributionToGrid = (cells: Cell[]) => {
const width = Math.max(0, ...cells.map((c) => c.x)) + 1;
const height = Math.max(0, ...cells.map((c) => c.y)) + 1;
const grid = createEmptyGrid(width, height);
for (const c of cells) if (c.k) setColor(grid, c.x, c.y, c.k as Color);
return grid;
};