mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-27 00:04:37 +08:00
converted to ts
This commit is contained in:
parent
0d66afe2be
commit
99e24a92a1
1 changed files with 6 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
|||
let accents = [
|
||||
const accents: [string, string][] = [
|
||||
["áàâäåãąą́āą̄ă", "a"],
|
||||
["éèêëẽęę́ēę̄ėě", "e"],
|
||||
["íìîïĩįį́īį̄", "i"],
|
||||
|
@ -31,11 +31,14 @@ let accents = [
|
|||
["ّ", ""],
|
||||
];
|
||||
|
||||
export function replaceAccents(word, accentsOverride) {
|
||||
export function replaceAccents(
|
||||
word: string,
|
||||
accentsOverride?: [accents: string, replace: string][]
|
||||
): string {
|
||||
let newWord = word;
|
||||
if (!accents && !accentsOverride) return newWord;
|
||||
let regex;
|
||||
let list = accentsOverride || accents;
|
||||
const list = accentsOverride || accents;
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
regex = new RegExp(`[${list[i][0]}]`, "gi");
|
||||
newWord = newWord.replace(regex, list[i][1]);
|
Loading…
Reference in a new issue