hebrew-transliteration 2.1.1 → 2.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/dist/index.js CHANGED
@@ -1,435 +1,13 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
23
- Schema: () => Schema,
24
- Text: () => import_havarotjs3.Text,
25
- remove: () => remove,
26
- sequence: () => sequence,
27
- transliterate: () => transliterate
28
- });
29
- module.exports = __toCommonJS(src_exports);
30
- var import_havarotjs3 = require("havarotjs");
31
-
32
- // src/rules.ts
33
- var import_cluster = require("havarotjs/dist/cluster");
34
-
35
- // src/hebCharsTrans.ts
36
- var transliterateMap = {
37
- "\u05B0": "VOCAL_SHEVA",
38
- "\u05B1": "HATAF_SEGOL",
39
- "\u05B2": "HATAF_PATAH",
40
- "\u05B3": "HATAF_QAMATS",
41
- "\u05B4": "HIRIQ",
42
- "\u05B5": "TSERE",
43
- "\u05B6": "SEGOL",
44
- "\u05B7": "PATAH",
45
- "\u05B8": "QAMATS",
46
- "\u05B9": "HOLAM",
47
- "\u05BA": "HOLAM",
48
- "\u05BB": "QUBUTS",
49
- "\u05BC": "DAGESH",
50
- "\u05BE": "MAQAF",
51
- "\u05C0": "PASEQ",
52
- "\u05C3": "SOF_PASUQ",
53
- "\u05C7": "QAMATS_QATAN",
54
- \u05D0: "ALEF",
55
- \u05D1: "BET",
56
- \u05D2: "GIMEL",
57
- \u05D3: "DALET",
58
- \u05D4: "HE",
59
- \u05D5: "VAV",
60
- \u05D6: "ZAYIN",
61
- \u05D7: "HET",
62
- \u05D8: "TET",
63
- \u05D9: "YOD",
64
- \u05DA: "FINAL_KAF",
65
- \u05DB: "KAF",
66
- \u05DC: "LAMED",
67
- \u05DD: "FINAL_MEM",
68
- \u05DE: "MEM",
69
- \u05DF: "FINAL_NUN",
70
- \u05E0: "NUN",
71
- \u05E1: "SAMEKH",
72
- \u05E2: "AYIN",
73
- \u05E3: "FINAL_PE",
74
- \u05E4: "PE",
75
- \u05E5: "FINAL_TSADI",
76
- \u05E6: "TSADI",
77
- \u05E7: "QOF",
78
- \u05E8: "RESH",
79
- \u05E9: "SHIN",
80
- \u05EA: "TAV"
81
- };
82
-
83
- // src/mapChars.ts
84
- var mapChars = (text, schema) => [...text].map((char) => char in transliterateMap ? schema[transliterateMap[char]] : char).join("");
85
-
86
- // src/rules.ts
87
- var taamim = /[\u{0590}-\u{05AF}\u{05BD}\u{05BF}]/u;
88
- var changeElementSplit = (input, split, join) => input.split(split).join(join);
89
- var consonantFeatures = (clusterText, syl, cluster, schema) => {
90
- var _a;
91
- if ((_a = schema.ADDITIONAL_FEATURES) == null ? void 0 : _a.length) {
92
- const clusterSeqs = schema.ADDITIONAL_FEATURES.filter((s) => s.FEATURE === "cluster");
93
- for (const seq of clusterSeqs) {
94
- const heb = new RegExp(seq.HEBREW, "u");
95
- if (heb.test(clusterText)) {
96
- const sylSeq = changeElementSplit(clusterText, heb, seq.TRANSLITERATION);
97
- return [...sylSeq].map((char) => mapChars(char, schema)).join("");
98
- }
99
- }
100
- }
101
- clusterText = cluster.hasShewa && syl.isClosed ? clusterText.replace(/\u{05B0}/u, "") : clusterText;
102
- if (/ה\u{05BC}$/mu.test(clusterText)) {
103
- return changeElementSplit(clusterText, /ה\u{05BC}/u, schema.HE);
104
- }
105
- if (syl.isFinal && !syl.isClosed) {
106
- const furtiveChet = /\u{05D7}\u{05B7}$/mu;
107
- if (furtiveChet.test(clusterText)) {
108
- return changeElementSplit(clusterText, furtiveChet, "\u05B7\u05D7");
109
- }
110
- const furtiveAyin = /\u{05E2}\u{05B7}$/mu;
111
- if (furtiveAyin.test(clusterText)) {
112
- return changeElementSplit(clusterText, furtiveAyin, "\u05B7\u05E2");
113
- }
114
- const furtiveHe = /\u{05D4}\u{05BC}\u{05B7}$/mu;
115
- if (furtiveHe.test(clusterText)) {
116
- return changeElementSplit(clusterText, furtiveHe, "\u05B7\u05D4\u05BC");
117
- }
118
- }
119
- const prevHasVowel = cluster.prev instanceof import_cluster.Cluster ? cluster.prev.hasVowel : false;
120
- const isDoubled = schema.DAGESH_CHAZAQ && prevHasVowel && /\u{05BC}/u.test(clusterText);
121
- if (schema.BET_DAGESH && /ב\u{05BC}/u.test(clusterText)) {
122
- return changeElementSplit(clusterText, /ב\u{05BC}/u, schema.BET_DAGESH.repeat(isDoubled ? 2 : 1));
123
- }
124
- if (schema.GIMEL_DAGESH && /ג\u{05BC}/u.test(clusterText)) {
125
- return changeElementSplit(clusterText, /ג\u{05BC}/u, schema.GIMEL_DAGESH.repeat(isDoubled ? 2 : 1));
126
- }
127
- if (schema.DALET_DAGESH && /ד\u{05BC}/u.test(clusterText)) {
128
- return changeElementSplit(clusterText, /ד\u{05BC}/u, schema.DALET_DAGESH.repeat(isDoubled ? 2 : 1));
129
- }
130
- if (schema.KAF_DAGESH && /כ\u{05BC}/u.test(clusterText)) {
131
- return changeElementSplit(clusterText, /כ\u{05BC}/u, schema.KAF_DAGESH.repeat(isDoubled ? 2 : 1));
132
- }
133
- if (schema.KAF_DAGESH && /ך\u{05BC}/u.test(clusterText)) {
134
- return changeElementSplit(clusterText, /ך\u{05BC}/u, schema.KAF_DAGESH.repeat(isDoubled ? 2 : 1));
135
- }
136
- if (schema.PE_DAGESH && /פ\u{05BC}/u.test(clusterText)) {
137
- return changeElementSplit(clusterText, /פ\u{05BC}/u, schema.PE_DAGESH.repeat(isDoubled ? 2 : 1));
138
- }
139
- if (schema.TAV_DAGESH && /ת\u{05BC}/u.test(clusterText)) {
140
- return changeElementSplit(clusterText, /ת\u{05BC}/u, schema.TAV_DAGESH.repeat(isDoubled ? 2 : 1));
141
- }
142
- if (/ש\u{05C1}/u.test(clusterText)) {
143
- return changeElementSplit(clusterText, /ש\u{05C1}/u, schema.SHIN.repeat(isDoubled ? 2 : 1));
144
- }
145
- if (/ש\u{05C2}/u.test(clusterText)) {
146
- return changeElementSplit(clusterText, /ש\u{05C2}/u, schema.SIN.repeat(isDoubled ? 2 : 1));
147
- }
148
- if (isDoubled) {
149
- const consonant = cluster.chars[0].text;
150
- const consonantDagesh = new RegExp(consonant + "\u05BC", "u");
151
- return changeElementSplit(clusterText, consonantDagesh, `${consonant + consonant}`);
152
- }
153
- if (cluster.isShureq) {
154
- return schema.SHUREQ;
155
- }
156
- return clusterText;
157
- };
158
- var materFeatures = (syl, schema) => {
159
- const mater = syl.clusters.filter((c) => c.isMater)[0];
160
- const prev = mater.prev instanceof import_cluster.Cluster ? mater.prev : null;
161
- const materText = mater.text;
162
- const prevText = ((prev == null ? void 0 : prev.text) || "").replace(taamim, "");
163
- let noMaterText = syl.clusters.filter((c) => !c.isMater).map((c) => consonantFeatures(c.text.replace(taamim, ""), syl, c, schema)).join("");
164
- const hasMaqaf = mater.text.includes("\u05BE");
165
- noMaterText = hasMaqaf ? noMaterText.concat("\u05BE") : noMaterText;
166
- if (/י/.test(materText)) {
167
- if (/\u{05B4}/u.test(prevText)) {
168
- return changeElementSplit(noMaterText, /\u{05B4}/u, schema.HIRIQ_YOD);
169
- }
170
- if (/\u{05B5}/u.test(prevText)) {
171
- return changeElementSplit(noMaterText, /\u{05B5}/u, schema.TSERE_YOD);
172
- }
173
- if (/\u{05B6}/u.test(prevText)) {
174
- return changeElementSplit(noMaterText, /\u{05B6}/u, schema.SEGOL_YOD);
175
- }
176
- }
177
- if (/ו/u.test(materText)) {
178
- if (/\u{05B9}/u.test(prevText)) {
179
- return changeElementSplit(noMaterText, /\u{05B9}/u, schema.HOLAM_VAV);
180
- }
181
- }
182
- if (/ה/.test(materText)) {
183
- if (/\u{05B8}/u.test(prevText)) {
184
- return changeElementSplit(noMaterText, /\u{05B8}/u, schema.QAMATS_HE);
185
- }
186
- if (/\u{05B6}/u.test(prevText)) {
187
- return changeElementSplit(noMaterText, /\u{05B6}/u, schema.SEGOL_HE);
188
- }
189
- if (/\u{05B5}/u.test(prevText)) {
190
- return changeElementSplit(noMaterText, /\u{05B5}/u, schema.SEGOL_HE);
191
- }
192
- }
193
- return materText;
194
- };
195
- var joinChars = (isAccented, sylChars, schema) => {
196
- if (!isAccented) {
197
- return sylChars.map((char) => mapChars(char, schema)).join("");
198
- }
199
- if (schema.STRESS_MARKER) {
200
- const location = schema.STRESS_MARKER.location;
201
- const mark = schema.STRESS_MARKER.mark;
202
- if (location === "before-syllable") {
203
- return `${mark}${sylChars.map((char) => mapChars(char, schema)).join("")}`;
204
- }
205
- if (location === "after-syllable") {
206
- return `${sylChars.map((char) => mapChars(char, schema)).join("")}${mark}`;
207
- }
208
- const vowels3 = [
209
- schema.PATAH,
210
- schema.HATAF_PATAH,
211
- schema.QAMATS,
212
- schema.HATAF_QAMATS,
213
- schema.SEGOL,
214
- schema.HATAF_SEGOL,
215
- schema.TSERE,
216
- schema.HIRIQ,
217
- schema.HOLAM,
218
- schema.QAMATS_QATAN,
219
- schema.QUBUTS,
220
- schema.QAMATS_HE,
221
- schema.SEGOL_HE,
222
- schema.TSERE_HE,
223
- schema.HIRIQ_YOD,
224
- schema.TSERE_YOD,
225
- schema.SEGOL_YOD,
226
- schema.HOLAM_VAV,
227
- schema.SHUREQ
228
- ].sort((a, b) => b.length - a.length);
229
- const vowelRgx = new RegExp(`${vowels3.join("|")}`);
230
- const str = sylChars.map((char) => mapChars(char, schema)).join("");
231
- const match = str.match(vowelRgx);
232
- if (location === "before-vowel") {
233
- return (match == null ? void 0 : match.length) ? str.replace(match[0], `${mark}${match[0]}`) : str;
234
- }
235
- return (match == null ? void 0 : match.length) ? str.replace(match[0], `${match[0]}${mark}`) : str;
236
- }
237
- return sylChars.map((char) => mapChars(char, schema)).join("");
238
- };
239
- var sylRules = (syl, schema) => {
240
- var _a;
241
- const sylTxt = syl.text.replace(taamim, "");
242
- if ((_a = schema.ADDITIONAL_FEATURES) == null ? void 0 : _a.length) {
243
- const sylSeqs = schema.ADDITIONAL_FEATURES.filter((s) => s.FEATURE === "syllable");
244
- for (const seq of sylSeqs) {
245
- const heb = new RegExp(seq.HEBREW, "u");
246
- if (heb.test(sylTxt)) {
247
- const wordSeq = changeElementSplit(sylTxt, heb, seq.TRANSLITERATION);
248
- return joinChars(syl.isAccented, [...wordSeq], schema);
249
- }
250
- }
251
- }
252
- const mSSuffix = /\u{05B8}\u{05D9}\u{05D5}/u;
253
- if (syl.isFinal && mSSuffix.test(sylTxt)) {
254
- const sufxSyl = changeElementSplit(sylTxt, mSSuffix, schema.MS_SUFX);
255
- return joinChars(syl.isAccented, [...sufxSyl], schema);
256
- }
257
- const hasMater = syl.clusters.map((c) => c.isMater).includes(true);
258
- if (hasMater) {
259
- const materSyl = materFeatures(syl, schema);
260
- return joinChars(syl.isAccented, [...materSyl], schema);
261
- }
262
- const returnTxt = syl.clusters.map((cluster) => {
263
- const clusterText = cluster.text.replace(taamim, "");
264
- return consonantFeatures(clusterText, syl, cluster, schema);
265
- });
266
- return joinChars(syl.isAccented, returnTxt, schema);
267
- };
268
- var wordRules = (word, schema) => {
269
- var _a;
270
- if (word.isDivineName)
271
- return schema.DIVINE_NAME;
272
- if (word.hasDivineName)
273
- return `${sylRules(word.syllables[0], schema)}-${schema.DIVINE_NAME}`;
274
- if (word.isNotHebrew)
275
- return word.text;
276
- if ((_a = schema.ADDITIONAL_FEATURES) == null ? void 0 : _a.length) {
277
- const wordSeqs = schema.ADDITIONAL_FEATURES.filter((s) => s.FEATURE === "word");
278
- for (const seq of wordSeqs) {
279
- const heb = new RegExp(seq.HEBREW, "u");
280
- const wordText = word.text.replace(taamim, "");
281
- if (heb.test(wordText)) {
282
- const wordSeq = changeElementSplit(wordText, heb, seq.TRANSLITERATION);
283
- return [...wordSeq].map((char) => mapChars(char, schema)).join("");
284
- }
285
- }
286
- }
287
- return word;
288
- };
289
-
290
- // src/schema.ts
291
- var Schema = class {
292
- constructor(schema) {
293
- this.VOCAL_SHEVA = schema.VOCAL_SHEVA, this.HATAF_SEGOL = schema.HATAF_SEGOL, this.HATAF_PATAH = schema.HATAF_PATAH, this.HATAF_QAMATS = schema.HATAF_QAMATS, this.HIRIQ = schema.HIRIQ, this.TSERE = schema.TSERE, this.SEGOL = schema.SEGOL, this.PATAH = schema.PATAH, this.QAMATS = schema.QAMATS, this.HOLAM = schema.HOLAM, this.QUBUTS = schema.QUBUTS, this.DAGESH = schema.DAGESH, this.DAGESH_CHAZAQ = schema.DAGESH_CHAZAQ, this.MAQAF = schema.MAQAF, this.PASEQ = schema.PASEQ, this.SOF_PASUQ = schema.SOF_PASUQ, this.QAMATS_QATAN = schema.QAMATS_QATAN, this.FURTIVE_PATAH = schema.FURTIVE_PATAH, this.HIRIQ_YOD = schema.HIRIQ_YOD, this.TSERE_YOD = schema.TSERE_YOD, this.SEGOL_YOD = schema.SEGOL_YOD, this.SHUREQ = schema.SHUREQ, this.HOLAM_VAV = schema.HOLAM_VAV, this.QAMATS_HE = schema.QAMATS_HE, this.SEGOL_HE = schema.SEGOL_HE, this.TSERE_HE = schema.TSERE_HE, this.MS_SUFX = schema.MS_SUFX, this.ALEF = schema.ALEF, this.BET_DAGESH = schema.BET_DAGESH, this.BET = schema.BET, this.GIMEL = schema.GIMEL, this.GIMEL_DAGESH = schema.GIMEL_DAGESH, this.DALET = schema.DALET, this.DALET_DAGESH = schema.DALET_DAGESH, this.HE = schema.HE, this.VAV = schema.VAV, this.ZAYIN = schema.ZAYIN, this.HET = schema.HET, this.TET = schema.TET, this.YOD = schema.YOD, this.FINAL_KAF = schema.FINAL_KAF, this.KAF = schema.KAF, this.KAF_DAGESH = schema.KAF_DAGESH, this.LAMED = schema.LAMED, this.FINAL_MEM = schema.FINAL_MEM, this.MEM = schema.MEM, this.FINAL_NUN = schema.FINAL_NUN, this.NUN = schema.NUN, this.SAMEKH = schema.SAMEKH, this.AYIN = schema.AYIN, this.FINAL_PE = schema.FINAL_PE, this.PE = schema.PE, this.PE_DAGESH = schema.PE_DAGESH, this.FINAL_TSADI = schema.FINAL_TSADI, this.TSADI = schema.TSADI, this.QOF = schema.QOF, this.RESH = schema.RESH, this.SHIN = schema.SHIN, this.SIN = schema.SIN, this.TAV = schema.TAV, this.TAV_DAGESH = schema.TAV_DAGESH, this.DIVINE_NAME = schema.DIVINE_NAME, this.SYLLABLE_SEPARATOR = schema.SYLLABLE_SEPARATOR, this.ADDITIONAL_FEATURES = schema.ADDITIONAL_FEATURES, this.STRESS_MARKER = schema.STRESS_MARKER, this.longVowels = schema.longVowels, this.qametsQatan = schema.qametsQatan, this.sqnmlvy = schema.sqnmlvy, this.wawShureq = schema.wawShureq, this.article = schema.article;
294
- this.allowNoNiqqud = schema.allowNoNiqqud;
295
- }
296
- };
297
- var SBL = class extends Schema {
298
- constructor(schema) {
299
- var _a, _b, _c, _d, _e, _f, _g;
300
- super({
301
- VOCAL_SHEVA: schema.VOCAL_SHEVA || "\u01DD",
302
- HATAF_SEGOL: schema.HATAF_SEGOL || "\u0115",
303
- HATAF_PATAH: schema.HATAF_PATAH || "\u0103",
304
- HATAF_QAMATS: schema.HATAF_QAMATS || "\u014F",
305
- HIRIQ: schema.HIRIQ || "i",
306
- TSERE: schema.TSERE || "\u0113",
307
- SEGOL: schema.SEGOL || "e",
308
- PATAH: schema.PATAH || "a",
309
- QAMATS: schema.QAMATS || "\u0101",
310
- HOLAM: schema.HOLAM || "\u014D",
311
- QUBUTS: schema.QUBUTS || "\u016B",
312
- DAGESH: schema.DAGESH || "",
313
- DAGESH_CHAZAQ: (_a = schema.DAGESH_CHAZAQ) != null ? _a : true,
314
- MAQAF: schema.MAQAF || "-",
315
- PASEQ: schema.PASEQ || "",
316
- SOF_PASUQ: schema.SOF_PASUQ || "",
317
- QAMATS_QATAN: schema.QAMATS_QATAN || "o",
318
- FURTIVE_PATAH: schema.FURTIVE_PATAH || "a",
319
- HIRIQ_YOD: schema.HIRIQ_YOD || "\xEE",
320
- TSERE_YOD: schema.TSERE_YOD || "\xEA",
321
- SEGOL_YOD: schema.SEGOL_YOD || "\xEA",
322
- SHUREQ: schema.SHUREQ || "\xFB",
323
- HOLAM_VAV: schema.HOLAM_VAV || "\xF4",
324
- QAMATS_HE: schema.QAMATS_HE || "\xE2",
325
- SEGOL_HE: schema.SEGOL_HE || "\xEA",
326
- TSERE_HE: schema.TSERE_HE || "\xEA",
327
- MS_SUFX: schema.MS_SUFX || "\u0101yw",
328
- ALEF: schema.ALEF || "\u02BE",
329
- BET: schema.BET || "b",
330
- BET_DAGESH: schema.BET_DAGESH || void 0,
331
- GIMEL: schema.GIMEL || "g",
332
- GIMEL_DAGESH: schema.GIMEL_DAGESH || void 0,
333
- DALET: schema.DALET || "d",
334
- DALET_DAGESH: schema.DALET_DAGESH || void 0,
335
- HE: schema.HE || "h",
336
- VAV: schema.VAV || "w",
337
- ZAYIN: schema.ZAYIN || "z",
338
- HET: schema.HET || "\u1E25",
339
- TET: schema.TET || "\u1E6D",
340
- YOD: schema.YOD || "y",
341
- FINAL_KAF: schema.FINAL_KAF || "k",
342
- KAF: schema.KAF || "k",
343
- KAF_DAGESH: schema.KAF_DAGESH || void 0,
344
- LAMED: schema.LAMED || "l",
345
- FINAL_MEM: schema.FINAL_MEM || "m",
346
- MEM: schema.MEM || "m",
347
- FINAL_NUN: schema.FINAL_NUN || "n",
348
- NUN: schema.NUN || "n",
349
- SAMEKH: schema.SAMEKH || "s",
350
- AYIN: schema.AYIN || "\u02BF",
351
- FINAL_PE: schema.FINAL_PE || "p",
352
- PE: schema.PE || "p",
353
- PE_DAGESH: schema.PE_DAGESH || void 0,
354
- FINAL_TSADI: schema.FINAL_TSADI || "\u1E63",
355
- TSADI: schema.TSADI || "\u1E63",
356
- QOF: schema.QOF || "q",
357
- RESH: schema.RESH || "r",
358
- SHIN: schema.SHIN || "\u0161",
359
- SIN: schema.SIN || "\u015B",
360
- TAV: schema.TAV || "t",
361
- TAV_DAGESH: schema.TAV_DAGESH || void 0,
362
- DIVINE_NAME: schema.DIVINE_NAME || "yhwh",
363
- SYLLABLE_SEPARATOR: schema.SYLLABLE_SEPARATOR || void 0,
364
- ADDITIONAL_FEATURES: schema.ADDITIONAL_FEATURES || void 0,
365
- STRESS_MARKER: schema.STRESS_MARKER || void 0,
366
- longVowels: (_b = schema.longVowels) != null ? _b : true,
367
- qametsQatan: (_c = schema.qametsQatan) != null ? _c : true,
368
- sqnmlvy: (_d = schema.sqnmlvy) != null ? _d : true,
369
- wawShureq: (_e = schema.wawShureq) != null ? _e : true,
370
- article: (_f = schema.article) != null ? _f : true,
371
- allowNoNiqqud: (_g = schema.allowNoNiqqud) != null ? _g : true
372
- });
373
- }
374
- };
375
-
376
- // src/transliterate.ts
377
- var import_havarotjs = require("havarotjs");
378
- var import_word = require("havarotjs/dist/word");
379
- var getSylOpts = (schema) => {
380
- const options = {};
381
- if ("longVowels" in schema)
382
- options.longVowels = schema.longVowels;
383
- if ("qametsQatan" in schema)
384
- options.qametsQatan = schema.qametsQatan;
385
- if ("sqnmlvy" in schema)
386
- options.sqnmlvy = schema.sqnmlvy;
387
- if ("wawShureq" in schema)
388
- options.wawShureq = schema.wawShureq;
389
- if ("article" in schema)
390
- options.article = schema.article;
391
- if ("allowNoNiqqud" in schema)
392
- options.allowNoNiqqud = schema.allowNoNiqqud;
393
- return options;
394
- };
395
- var transliterate = (text, schema) => {
396
- const transSchema = schema instanceof Schema ? schema : new SBL(schema != null ? schema : {});
397
- const newText = text instanceof import_havarotjs.Text ? text : new import_havarotjs.Text(text, getSylOpts(transSchema != null ? transSchema : {}));
398
- return newText.words.map((word) => {
399
- var _a, _b;
400
- let transliteration = wordRules(word, transSchema);
401
- if (transliteration instanceof import_word.Word) {
402
- transliteration = word.syllables.map((s) => sylRules(s, transSchema)).join((_a = transSchema.SYLLABLE_SEPARATOR) != null ? _a : "");
403
- }
404
- return `${transliteration}${(_b = word.whiteSpaceAfter) != null ? _b : ""}`;
405
- }).join("");
406
- };
407
-
408
- // src/sequence.ts
409
- var import_havarotjs2 = require("havarotjs");
410
- var vowels = /[\u{05B0}-\u{05BC}\u{05C7}]/u;
411
- var sequence = (text, qametsQatan = false) => {
412
- return vowels.test(text) ? new import_havarotjs2.Text(text, { qametsQatan }).text : text;
413
- };
414
-
415
- // src/remove.ts
416
- var cantillation = /[\u{0591}-\u{05AF}\u{05BF}\u{05C0}\u{05C3}-\u{05C6}\u{05F3}\u{05F4}]/gu;
417
- var vowels2 = /[\u{05B0}-\u{05BD}\u{05BF}\u{05C7}]/gu;
418
- var shinDot = /\u{05C1}/gu;
419
- var sinDot = /\u{05C2}/gu;
420
- var removeItem = (text, item) => text.replace(item, "");
421
- var remove = (text, { removeVowels = false, removeShinDot = false, removeSinDot = false } = {}) => {
422
- const sequenced = sequence(text);
423
- const remCantillation = removeItem(sequenced, cantillation);
424
- const remVowels = removeVowels ? removeItem(remCantillation, vowels2) : remCantillation;
425
- const remShin = removeShinDot ? removeItem(remVowels, shinDot) : remVowels;
426
- return removeSinDot ? removeItem(remShin, sinDot) : remShin;
427
- };
428
- // Annotate the CommonJS export names for ESM import in node:
429
- 0 && (module.exports = {
430
- Schema,
431
- Text,
432
- remove,
433
- sequence,
434
- transliterate
435
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.transliterate = exports.Text = exports.sequence = exports.Schema = exports.remove = void 0;
4
+ const havarotjs_1 = require("havarotjs");
5
+ Object.defineProperty(exports, "Text", { enumerable: true, get: function () { return havarotjs_1.Text; } });
6
+ const transliterate_1 = require("./transliterate");
7
+ Object.defineProperty(exports, "transliterate", { enumerable: true, get: function () { return transliterate_1.transliterate; } });
8
+ const sequence_1 = require("./sequence");
9
+ Object.defineProperty(exports, "sequence", { enumerable: true, get: function () { return sequence_1.sequence; } });
10
+ const remove_1 = require("./remove");
11
+ Object.defineProperty(exports, "remove", { enumerable: true, get: function () { return remove_1.remove; } });
12
+ const schema_1 = require("./schema");
13
+ Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return schema_1.Schema; } });
@@ -0,0 +1,10 @@
1
+ import { Schema } from "./schema";
2
+ /**
3
+ * maps single Hebrew characters to transliteration characters according to the schema
4
+ *
5
+ * @param text - a single character
6
+ * @param schema - a {@link Schema} for transliterating the text
7
+ * @returns transliteration of single characters according to the schema
8
+ *
9
+ */
10
+ export declare const mapChars: (text: string, schema: Schema) => string;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapChars = void 0;
4
+ const hebCharsTrans_1 = require("./hebCharsTrans");
5
+ /**
6
+ * maps single Hebrew characters to transliteration characters according to the schema
7
+ *
8
+ * @param text - a single character
9
+ * @param schema - a {@link Schema} for transliterating the text
10
+ * @returns transliteration of single characters according to the schema
11
+ *
12
+ */
13
+ const mapChars = (text, schema) => [...text].map((char) => (char in hebCharsTrans_1.transliterateMap ? schema[hebCharsTrans_1.transliterateMap[char]] : char)).join("");
14
+ exports.mapChars = mapChars;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Options for the `remove()` function
3
+ */
4
+ interface RemoveOptions {
5
+ /**
6
+ * an option to remove vowels
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * heb.remove("שָׂרַ֣י אִשְׁתְּךָ֔", { removeVowels: true });
11
+ * // "שׂרי אשׁתך";
12
+ * ```
13
+ */
14
+ removeVowels?: boolean;
15
+ /**
16
+ * an option to remove the shin dot (U+05C1)
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * heb.remove("שָׂרַ֣י אִשְׁתְּךָ֔", { removeVowels: true, removeShinDot: true, removeSinDot: true });
21
+ * // "שרי אשתך";
22
+ * ```
23
+ */
24
+ removeShinDot?: boolean;
25
+ /**
26
+ * an option to remove the sin dot (U+05C2)
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * heb.remove("שָׂרַ֣י אִשְׁתְּךָ֔", { removeVowels: true, removeShinDot: true, removeSinDot: true });
31
+ * // "שרי אשתך";
32
+ * ```
33
+ */
34
+ removeSinDot?: boolean;
35
+ }
36
+ /**
37
+ * removes taamim and optionally removes certain niqqudim
38
+ *
39
+ * @param text - a string of Hebrew characters
40
+ * @param RemoveOptions - {@link RemoveOptions}
41
+ * @returns Hebrew characters with taamim and niqqud optionally removed
42
+ *
43
+ * @example Default
44
+ *
45
+ * ```ts
46
+ * heb.remove("שָׂרַ֣י אִשְׁתְּךָ֔");
47
+ * // "שָׂרַי אִשְׁתְּךָ";
48
+ * ```
49
+ *
50
+ * @example Remove vowels
51
+ *
52
+ * ```ts
53
+ * heb.remove("שָׂרַ֣י אִשְׁתְּךָ֔", { removeVowels: true });
54
+ * // "שׂרי אשׁתך";
55
+ * ```
56
+ *
57
+ * @example Remove all
58
+ *
59
+ * ```ts
60
+ * heb.remove("שָׂרַ֣י אִשְׁתְּךָ֔", { removeVowels: true, removeShinDot: true, removeSinDot: true });
61
+ * // "שרי אשתך";
62
+ * ```
63
+ */
64
+ export declare const remove: (text: string, { removeVowels, removeShinDot, removeSinDot }?: RemoveOptions) => string;
65
+ export {};
package/dist/remove.js ADDED
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.remove = void 0;
4
+ const sequence_1 = require("./sequence");
5
+ const cantillation = /[\u{0591}-\u{05AF}\u{05BF}\u{05C0}\u{05C3}-\u{05C6}\u{05F3}\u{05F4}]/gu;
6
+ const vowels = /[\u{05B0}-\u{05BD}\u{05BF}\u{05C7}]/gu;
7
+ const shinDot = /\u{05C1}/gu;
8
+ const sinDot = /\u{05C2}/gu;
9
+ const removeItem = (text, item) => text.replace(item, "");
10
+ /**
11
+ * removes taamim and optionally removes certain niqqudim
12
+ *
13
+ * @param text - a string of Hebrew characters
14
+ * @param RemoveOptions - {@link RemoveOptions}
15
+ * @returns Hebrew characters with taamim and niqqud optionally removed
16
+ *
17
+ * @example Default
18
+ *
19
+ * ```ts
20
+ * heb.remove("שָׂרַ֣י אִשְׁתְּךָ֔");
21
+ * // "שָׂרַי אִשְׁתְּךָ";
22
+ * ```
23
+ *
24
+ * @example Remove vowels
25
+ *
26
+ * ```ts
27
+ * heb.remove("שָׂרַ֣י אִשְׁתְּךָ֔", { removeVowels: true });
28
+ * // "שׂרי אשׁתך";
29
+ * ```
30
+ *
31
+ * @example Remove all
32
+ *
33
+ * ```ts
34
+ * heb.remove("שָׂרַ֣י אִשְׁתְּךָ֔", { removeVowels: true, removeShinDot: true, removeSinDot: true });
35
+ * // "שרי אשתך";
36
+ * ```
37
+ */
38
+ const remove = (text, { removeVowels = false, removeShinDot = false, removeSinDot = false } = {}) => {
39
+ const sequenced = (0, sequence_1.sequence)(text);
40
+ const remCantillation = removeItem(sequenced, cantillation);
41
+ const remVowels = removeVowels ? removeItem(remCantillation, vowels) : remCantillation;
42
+ const remShin = removeShinDot ? removeItem(remVowels, shinDot) : remVowels;
43
+ return removeSinDot ? removeItem(remShin, sinDot) : remShin;
44
+ };
45
+ exports.remove = remove;
@@ -0,0 +1,5 @@
1
+ import { Syllable } from "havarotjs/dist/syllable";
2
+ import { Word } from "havarotjs/dist/word";
3
+ import { Schema } from "./schema";
4
+ export declare const sylRules: (syl: Syllable, schema: Schema) => string;
5
+ export declare const wordRules: (word: Word, schema: Schema) => string | Word;