@orama/orama
Version:
A complete search engine and RAG pipeline in your browser, server, or edge network with support for full-text, vector, and hybrid search in less than 2kb.
210 lines • 2.27 kB
JavaScript
const DIACRITICS_CHARCODE_START = 192;
const DIACRITICS_CHARCODE_END = 383;
const CHARCODE_REPLACE_MAPPING = [
65,
65,
65,
65,
65,
65,
65,
67,
69,
69,
69,
69,
73,
73,
73,
73,
69,
78,
79,
79,
79,
79,
79,
null,
79,
85,
85,
85,
85,
89,
80,
115,
97,
97,
97,
97,
97,
97,
97,
99,
101,
101,
101,
101,
105,
105,
105,
105,
101,
110,
111,
111,
111,
111,
111,
null,
111,
117,
117,
117,
117,
121,
112,
121,
65,
97,
65,
97,
65,
97,
67,
99,
67,
99,
67,
99,
67,
99,
68,
100,
68,
100,
69,
101,
69,
101,
69,
101,
69,
101,
69,
101,
71,
103,
71,
103,
71,
103,
71,
103,
72,
104,
72,
104,
73,
105,
73,
105,
73,
105,
73,
105,
73,
105,
73,
105,
74,
106,
75,
107,
107,
76,
108,
76,
108,
76,
108,
76,
108,
76,
108,
78,
110,
78,
110,
78,
110,
110,
78,
110,
79,
111,
79,
111,
79,
111,
79,
111,
82,
114,
82,
114,
82,
114,
83,
115,
83,
115,
83,
115,
83,
115,
84,
116,
84,
116,
84,
116,
85,
117,
85,
117,
85,
117,
85,
117,
85,
117,
85,
117,
87,
119,
89,
121,
89,
90,
122,
90,
122,
90,
122,
115
];
function replaceChar(charCode) {
if (charCode < DIACRITICS_CHARCODE_START || charCode > DIACRITICS_CHARCODE_END)
return charCode;
/* c8 ignore next */
return CHARCODE_REPLACE_MAPPING[charCode - DIACRITICS_CHARCODE_START] || charCode;
}
export function replaceDiacritics(str) {
const stringCharCode = [];
for (let idx = 0; idx < str.length; idx++) {
stringCharCode[idx] = replaceChar(str.charCodeAt(idx));
}
return String.fromCharCode(...stringCharCode);
}
//# sourceMappingURL=diacritics.js.map