Skip to content

Commit c8f6f44

Browse files
committed
refactor
1 parent a75a7e4 commit c8f6f44

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/parser/ucsur.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// https://www.kreativekorp.com/ucsur/charts/sitelen.html
22

3+
import { WORD_UNIT_RULES } from "./filter.ts";
4+
35
export const START_OF_CARTOUCHE = "\u{F1990}";
46
export const END_OF_CARTOUCHE = "\u{F1991}";
57
export const COMBINING_CARTOUCHE_EXTENSION = "\u{F1992}";
@@ -180,11 +182,14 @@ export const KU_LILI = [
180182
"majuna",
181183
"powe",
182184
];
183-
export const UCSUR_TO_LATIN: Map<string, string> = new Map([
184-
...[...PU, ...KU_SULI]
185-
.map((latin, i) => [String.fromCodePoint(0xF1900 + i), latin] as const),
186-
...KU_LILI
187-
.map((latin, i) => [String.fromCodePoint(0xF19A0 + i), latin] as const),
188-
]);
185+
export const UCSUR_TO_LATIN: Map<string, string> = new Map(
186+
[
187+
{ start: 0xF1900, words: [...PU, ...KU_SULI] } as const,
188+
{ start: 0xF19A0, words: KU_LILI } as const,
189+
]
190+
.flatMap(({ start, words }) =>
191+
words.map((latin, i) => [String.fromCodePoint(start + i), latin] as const)
192+
),
193+
);
189194
export const UCSUR_CHARACTER_REGEX =
190195
/[\u{F1900}-\u{F1988}\u{F19A0}-\u{F19A3}]/u;

0 commit comments

Comments
 (0)