cizgile 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -31
- package/dist/index.d.mts +41 -2
- package/dist/index.mjs +112 -56
- package/dist/shared/locales-latin-Bm94HAeL.mjs +595 -0
- package/dist/shared/percent-DG-pZhJI.mjs +268 -0
- package/dist/shared/types-DbyhfPRc.d.mts +24 -0
- package/dist/transliterate.d.mts +126 -12
- package/dist/transliterate.mjs +545 -3
- package/dist/uri.d.mts +125 -0
- package/dist/uri.mjs +457 -5
- package/package.json +7 -2
- package/dist/shared/iri-CzbwHYgr.mjs +0 -572
- package/dist/shared/locales-latin-D8enWKzw.mjs +0 -372
- package/dist/shared/types-C1iMvUXh.d.mts +0 -13
|
@@ -1,372 +0,0 @@
|
|
|
1
|
-
//#region src/transliterate/latin.ts
|
|
2
|
-
const latin = {
|
|
3
|
-
Æ: "AE",
|
|
4
|
-
æ: "ae",
|
|
5
|
-
Ø: "O",
|
|
6
|
-
ø: "o",
|
|
7
|
-
Ǿ: "O",
|
|
8
|
-
ǿ: "o",
|
|
9
|
-
Ð: "D",
|
|
10
|
-
ð: "d",
|
|
11
|
-
Þ: "TH",
|
|
12
|
-
þ: "th",
|
|
13
|
-
ß: "ss",
|
|
14
|
-
ẞ: "SS",
|
|
15
|
-
Œ: "OE",
|
|
16
|
-
œ: "oe",
|
|
17
|
-
Ł: "L",
|
|
18
|
-
ł: "l",
|
|
19
|
-
Đ: "D",
|
|
20
|
-
đ: "d",
|
|
21
|
-
ı: "i",
|
|
22
|
-
İ: "I",
|
|
23
|
-
Ħ: "H",
|
|
24
|
-
ħ: "h",
|
|
25
|
-
Ŧ: "T",
|
|
26
|
-
ŧ: "t",
|
|
27
|
-
Ŋ: "NG",
|
|
28
|
-
ŋ: "ng",
|
|
29
|
-
ĸ: "k",
|
|
30
|
-
ſ: "s",
|
|
31
|
-
IJ: "IJ",
|
|
32
|
-
ij: "ij",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86
|
-
//#region src/transliterate/symbols.ts
|
|
87
|
-
const symbols = {
|
|
88
|
-
"&": " and ",
|
|
89
|
-
"©": " c ",
|
|
90
|
-
"®": " r ",
|
|
91
|
-
"™": " tm ",
|
|
92
|
-
"℠": " sm ",
|
|
93
|
-
"♥": " love ",
|
|
94
|
-
"❤": " love ",
|
|
95
|
-
"🦄": " unicorn ",
|
|
96
|
-
"€": " euro ",
|
|
97
|
-
"£": " pound ",
|
|
98
|
-
"¥": " yen ",
|
|
99
|
-
"¢": " cent ",
|
|
100
|
-
"₺": " lira ",
|
|
101
|
-
"₹": " rupee ",
|
|
102
|
-
"₽": " ruble ",
|
|
103
|
-
"₩": " won ",
|
|
104
|
-
"₪": " shekel ",
|
|
105
|
-
"₫": " dong ",
|
|
106
|
-
"₴": " hryvnia ",
|
|
107
|
-
"₦": " naira ",
|
|
108
|
-
"฿": " baht ",
|
|
109
|
-
"°": " deg ",
|
|
110
|
-
"№": " no ",
|
|
111
|
-
µ: " u ",
|
|
112
|
-
"×": " x ",
|
|
113
|
-
"∞": " infinity ",
|
|
114
|
-
"∑": " sum ",
|
|
115
|
-
"√": " sqrt ",
|
|
116
|
-
π: " pi ",
|
|
117
|
-
"§": " section ",
|
|
118
|
-
"¶": " paragraph ",
|
|
119
|
-
"†": " ",
|
|
120
|
-
"‡": " ",
|
|
121
|
-
"•": " ",
|
|
122
|
-
"…": " ",
|
|
123
|
-
"–": " ",
|
|
124
|
-
"—": " ",
|
|
125
|
-
"«": " ",
|
|
126
|
-
"»": " ",
|
|
127
|
-
"“": " ",
|
|
128
|
-
"”": " ",
|
|
129
|
-
"„": " ",
|
|
130
|
-
"‘": "",
|
|
131
|
-
"’": "",
|
|
132
|
-
"‚": ""
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
//#endregion
|
|
136
|
-
//#region src/transliterate/core.ts
|
|
137
|
-
const DEFAULT_TABLES = [latin, symbols];
|
|
138
|
-
let sequenceCache;
|
|
139
|
-
function codePointCount(text) {
|
|
140
|
-
let count = 0;
|
|
141
|
-
for (const _ of text) count += 1;
|
|
142
|
-
return count;
|
|
143
|
-
}
|
|
144
|
-
function sequencesOf(table) {
|
|
145
|
-
sequenceCache ??= /* @__PURE__ */ new WeakMap();
|
|
146
|
-
const cached = sequenceCache.get(table);
|
|
147
|
-
if (cached !== void 0) return cached;
|
|
148
|
-
const multi = [];
|
|
149
|
-
for (const key of Object.keys(table)) if (codePointCount(key) > 1) multi.push([key, table[key] ?? ""]);
|
|
150
|
-
multi.sort((a, b) => b[0].length - a[0].length);
|
|
151
|
-
sequenceCache.set(table, multi);
|
|
152
|
-
return multi;
|
|
153
|
-
}
|
|
154
|
-
function resolveTables(options) {
|
|
155
|
-
const out = [];
|
|
156
|
-
if (options.locale !== void 0) {
|
|
157
|
-
out.push(options.locale.table);
|
|
158
|
-
if (options.locale.tables !== void 0) out.push(...options.locale.tables);
|
|
159
|
-
}
|
|
160
|
-
if (options.tables !== void 0) out.push(...options.tables);
|
|
161
|
-
out.push(...DEFAULT_TABLES);
|
|
162
|
-
return out;
|
|
163
|
-
}
|
|
164
|
-
function lookup(tables, key) {
|
|
165
|
-
for (const table of tables) {
|
|
166
|
-
const value = table[key];
|
|
167
|
-
if (value !== void 0) return value;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
function stripMarks(input) {
|
|
171
|
-
return input.normalize("NFD").replace(/\p{M}+/gu, "").normalize("NFC");
|
|
172
|
-
}
|
|
173
|
-
function fold(input, tables, dropUnknown, foldMarks = true) {
|
|
174
|
-
let text = input;
|
|
175
|
-
for (const table of tables) for (const [key, value] of sequencesOf(table)) if (text.includes(key)) text = text.split(key).join(value);
|
|
176
|
-
let out = "";
|
|
177
|
-
for (const ch of text) {
|
|
178
|
-
const direct = lookup(tables, ch);
|
|
179
|
-
if (direct !== void 0) {
|
|
180
|
-
out += direct;
|
|
181
|
-
continue;
|
|
182
|
-
}
|
|
183
|
-
if ((ch.codePointAt(0) ?? 0) < 128) {
|
|
184
|
-
out += ch;
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
const base = foldMarks ? stripMarks(ch) : ch;
|
|
188
|
-
if (base !== ch) {
|
|
189
|
-
if (base === "") continue;
|
|
190
|
-
out += lookup(tables, base) ?? (dropUnknown && (base.codePointAt(0) ?? 0) >= 128 ? "" : base);
|
|
191
|
-
continue;
|
|
192
|
-
}
|
|
193
|
-
out += dropUnknown ? "" : ch;
|
|
194
|
-
}
|
|
195
|
-
return out;
|
|
196
|
-
}
|
|
197
|
-
function transliterate(input, options = {}) {
|
|
198
|
-
return fold(input.normalize("NFC"), resolveTables(options), options.unknown === "drop");
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
//#endregion
|
|
202
|
-
//#region src/transliterate/locales-latin.ts
|
|
203
|
-
function turkishLowercase(input) {
|
|
204
|
-
return input.toLocaleLowerCase("tr");
|
|
205
|
-
}
|
|
206
|
-
const de = {
|
|
207
|
-
id: "de",
|
|
208
|
-
table: {
|
|
209
|
-
Ä: "Ae",
|
|
210
|
-
ä: "ae",
|
|
211
|
-
Ö: "Oe",
|
|
212
|
-
ö: "oe",
|
|
213
|
-
Ü: "Ue",
|
|
214
|
-
ü: "ue",
|
|
215
|
-
ß: "ss",
|
|
216
|
-
ẞ: "SS",
|
|
217
|
-
"&": " und "
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
const tr = {
|
|
221
|
-
id: "tr",
|
|
222
|
-
table: {
|
|
223
|
-
ı: "i",
|
|
224
|
-
İ: "I",
|
|
225
|
-
Ğ: "G",
|
|
226
|
-
ğ: "g",
|
|
227
|
-
Ş: "S",
|
|
228
|
-
ş: "s",
|
|
229
|
-
Ç: "C",
|
|
230
|
-
ç: "c",
|
|
231
|
-
Ö: "O",
|
|
232
|
-
ö: "o",
|
|
233
|
-
Ü: "U",
|
|
234
|
-
ü: "u",
|
|
235
|
-
"&": " ve "
|
|
236
|
-
},
|
|
237
|
-
lowercase: turkishLowercase
|
|
238
|
-
};
|
|
239
|
-
const az = {
|
|
240
|
-
id: "az",
|
|
241
|
-
table: {
|
|
242
|
-
ı: "i",
|
|
243
|
-
İ: "I",
|
|
244
|
-
Ğ: "G",
|
|
245
|
-
ğ: "g",
|
|
246
|
-
Ş: "S",
|
|
247
|
-
ş: "s",
|
|
248
|
-
Ç: "C",
|
|
249
|
-
ç: "c",
|
|
250
|
-
Ö: "O",
|
|
251
|
-
ö: "o",
|
|
252
|
-
Ü: "U",
|
|
253
|
-
ü: "u",
|
|
254
|
-
Ə: "E",
|
|
255
|
-
ə: "e",
|
|
256
|
-
"&": " ve "
|
|
257
|
-
},
|
|
258
|
-
lowercase: turkishLowercase
|
|
259
|
-
};
|
|
260
|
-
const da = {
|
|
261
|
-
id: "da",
|
|
262
|
-
table: {
|
|
263
|
-
Ø: "Oe",
|
|
264
|
-
ø: "oe",
|
|
265
|
-
Å: "Aa",
|
|
266
|
-
å: "aa",
|
|
267
|
-
Æ: "Ae",
|
|
268
|
-
æ: "ae",
|
|
269
|
-
"&": " og "
|
|
270
|
-
}
|
|
271
|
-
};
|
|
272
|
-
const nb = {
|
|
273
|
-
id: "nb",
|
|
274
|
-
table: {
|
|
275
|
-
Ø: "Oe",
|
|
276
|
-
ø: "oe",
|
|
277
|
-
Å: "Aa",
|
|
278
|
-
å: "aa",
|
|
279
|
-
Æ: "Ae",
|
|
280
|
-
æ: "ae",
|
|
281
|
-
"&": " og "
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
const sv = {
|
|
285
|
-
id: "sv",
|
|
286
|
-
table: {
|
|
287
|
-
Ä: "Ae",
|
|
288
|
-
ä: "ae",
|
|
289
|
-
Ö: "Oe",
|
|
290
|
-
ö: "oe",
|
|
291
|
-
Å: "Aa",
|
|
292
|
-
å: "aa",
|
|
293
|
-
"&": " och "
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
const fi = {
|
|
297
|
-
id: "fi",
|
|
298
|
-
table: {
|
|
299
|
-
Ä: "Ae",
|
|
300
|
-
ä: "ae",
|
|
301
|
-
Ö: "Oe",
|
|
302
|
-
ö: "oe",
|
|
303
|
-
Å: "Aa",
|
|
304
|
-
å: "aa",
|
|
305
|
-
"&": " ja "
|
|
306
|
-
}
|
|
307
|
-
};
|
|
308
|
-
const hu = {
|
|
309
|
-
id: "hu",
|
|
310
|
-
table: { "&": " es " }
|
|
311
|
-
};
|
|
312
|
-
const vi = {
|
|
313
|
-
id: "vi",
|
|
314
|
-
table: {
|
|
315
|
-
Đ: "D",
|
|
316
|
-
đ: "d",
|
|
317
|
-
"&": " va "
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
const es = {
|
|
321
|
-
id: "es",
|
|
322
|
-
table: {
|
|
323
|
-
Ñ: "N",
|
|
324
|
-
ñ: "n",
|
|
325
|
-
"&": " y "
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
const fr = {
|
|
329
|
-
id: "fr",
|
|
330
|
-
table: {
|
|
331
|
-
Œ: "Oe",
|
|
332
|
-
œ: "oe",
|
|
333
|
-
Æ: "Ae",
|
|
334
|
-
æ: "ae",
|
|
335
|
-
"&": " et "
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
const pt = {
|
|
339
|
-
id: "pt",
|
|
340
|
-
table: { "&": " e " }
|
|
341
|
-
};
|
|
342
|
-
const it = {
|
|
343
|
-
id: "it",
|
|
344
|
-
table: { "&": " e " }
|
|
345
|
-
};
|
|
346
|
-
const nl = {
|
|
347
|
-
id: "nl",
|
|
348
|
-
table: {
|
|
349
|
-
IJ: "IJ",
|
|
350
|
-
ij: "ij",
|
|
351
|
-
"&": " en "
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
const latinLocales = {
|
|
355
|
-
az,
|
|
356
|
-
da,
|
|
357
|
-
de,
|
|
358
|
-
es,
|
|
359
|
-
fi,
|
|
360
|
-
fr,
|
|
361
|
-
hu,
|
|
362
|
-
it,
|
|
363
|
-
nb,
|
|
364
|
-
nl,
|
|
365
|
-
pt,
|
|
366
|
-
sv,
|
|
367
|
-
tr,
|
|
368
|
-
vi
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
//#endregion
|
|
372
|
-
export { latin as C, symbols as S, fold as _, fi as a, stripMarks as b, it as c, nl as d, pt as f, DEFAULT_TABLES as g, vi as h, es as i, latinLocales as l, tr as m, da as n, fr as o, sv as p, de as r, hu as s, az as t, nb as u, lookup as v, transliterate as x, resolveTables as y };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//#region src/transliterate/types.d.ts
|
|
2
|
-
type TransliterationTable = Readonly<Record<string, string>>;
|
|
3
|
-
interface Locale {
|
|
4
|
-
readonly id: string;
|
|
5
|
-
readonly table: TransliterationTable;
|
|
6
|
-
readonly tables?: readonly TransliterationTable[];
|
|
7
|
-
readonly lowercase?: (input: string) => string;
|
|
8
|
-
}
|
|
9
|
-
type LatinLocaleId = "az" | "da" | "de" | "es" | "fi" | "fr" | "hu" | "it" | "nb" | "nl" | "pt" | "sv" | "tr" | "vi";
|
|
10
|
-
type CyrillicLocaleId = "bg" | "mk" | "ru" | "sr" | "uk";
|
|
11
|
-
type LocaleId = LatinLocaleId | CyrillicLocaleId;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { TransliterationTable as a, LocaleId as i, LatinLocaleId as n, Locale as r, CyrillicLocaleId as t };
|