diff --git a/logic/board.ts b/logic/board.ts index 0694189..f8713e0 100644 --- a/logic/board.ts +++ b/logic/board.ts @@ -16,7 +16,7 @@ export function createBoard(config: BoardConfig): BoardData { export function locateSection( { x, y }: CharacterPosition, - config: BoardConfig + config: BoardConfig, ): SectionPosition { return { sx: Math.floor(x / config.sectionWidth), diff --git a/logic/character.ts b/logic/character.ts index 3724fc3..d1b9f69 100644 --- a/logic/character.ts +++ b/logic/character.ts @@ -5,10 +5,11 @@ const printableASCIIRegex = /^[\x20-\x7E]$/; export function getCharacterWidth(ch: string): number { const segments = [...segmenter.segment(ch)]; - if (segments.length !== 1) + if (segments.length !== 1) { throw new Error( - `Expected exactly one grapheme cluster, got ${segments.length}.` + `Expected exactly one grapheme cluster, got ${segments.length}.`, ); + } const matchesASCII = ch.match(printableASCIIRegex); const matchesCJK = ch.match(cjkRegex); diff --git a/logic/section.ts b/logic/section.ts index cbc6206..e2d99f0 100644 --- a/logic/section.ts +++ b/logic/section.ts @@ -5,27 +5,28 @@ import type { SectionData, SectionPosition } from "../types/section.ts"; export function createSection( { sx, sy }: SectionPosition, - boardConfig: BoardConfig + boardConfig: BoardConfig, ): SectionData { - if (boardConfig.sectionWidth % 2 !== 0) + if (boardConfig.sectionWidth % 2 !== 0) { throw new Error( - "sectionWidth must be multiple of 2 (least common multiples of all character widths)" + "sectionWidth must be multiple of 2 (least common multiples of all character widths)", ); + } const offsetX = sx * boardConfig.sectionWidth; const offsetY = sy * boardConfig.sectionHeight; const ch: string[][] = Array(boardConfig.sectionHeight).fill( - Array(boardConfig.sectionWidth).fill(boardConfig.defaultCh) + Array(boardConfig.sectionWidth).fill(boardConfig.defaultCh), ); const color: string[][] = Array(boardConfig.sectionHeight).fill( - Array(boardConfig.sectionWidth).fill(boardConfig.defaultColor) + Array(boardConfig.sectionWidth).fill(boardConfig.defaultColor), ); const bgColor: string[][] = Array(boardConfig.sectionHeight).fill( - Array(boardConfig.sectionWidth).fill(boardConfig.defaultBgColor) + Array(boardConfig.sectionWidth).fill(boardConfig.defaultBgColor), ); const width: number[][] = Array(boardConfig.sectionHeight).fill( - Array(boardConfig.sectionWidth).fill(boardConfig.defaultWidth) + Array(boardConfig.sectionWidth).fill(boardConfig.defaultWidth), ); return { offsetX, offsetY, ch, color, bgColor, width }; diff --git a/tests/section.test.ts b/tests/section.test.ts index 51a58b2..0984ad2 100644 --- a/tests/section.test.ts +++ b/tests/section.test.ts @@ -23,7 +23,7 @@ Deno.test("section", async (t) => { defaultColor: "F", defaultBgColor: "0", defaultWidth: 1, - } + }, ); }); }); @@ -40,7 +40,7 @@ Deno.test("section", async (t) => { defaultColor: "F", defaultBgColor: "0", defaultWidth: 1, - } + }, ); assertEquals(section.offsetX, 4); @@ -59,7 +59,7 @@ Deno.test("section", async (t) => { defaultColor: "F", defaultBgColor: "0", defaultWidth: 1, - } + }, ); assertEquals(section.offsetX, 0); @@ -69,7 +69,7 @@ Deno.test("section", async (t) => { content: T[][], rowCount: number, columnCount: number, - value: T + value: T, ) { assertEquals(content.length, rowCount); for (const row of content) {