mirror of
https://github.com/TextPlace/CoreTextPlace.git
synced 2025-05-01 05:01:11 +00:00
chore: deno fmt everything
This commit is contained in:
parent
910b6519ae
commit
2836153a7f
4 changed files with 16 additions and 14 deletions
|
@ -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),
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 };
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue