hebrew-transliteration 2.0.0 → 2.0.3

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,14 +1,437 @@
1
- "use strict";
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; } });
14
- //# sourceMappingURL=index.js.map
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __reExport = (target, module2, copyDefault, desc) => {
11
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
12
+ for (let key of __getOwnPropNames(module2))
13
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
14
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
15
+ }
16
+ return target;
17
+ };
18
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
19
+ return (module2, temp) => {
20
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
21
+ };
22
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
23
+
24
+ // src/index.ts
25
+ var src_exports = {};
26
+ __export(src_exports, {
27
+ Schema: () => Schema,
28
+ Text: () => import_havarotjs3.Text,
29
+ remove: () => remove,
30
+ sequence: () => sequence,
31
+ transliterate: () => transliterate
32
+ });
33
+ var import_havarotjs3 = require("havarotjs");
34
+
35
+ // src/sequence.ts
36
+ var import_havarotjs = require("havarotjs");
37
+ var vowels = /[\u{05B0}-\u{05BD}\u{05BF}\u{05C7}]/u;
38
+ var sequence = (text, qametsQatan = false) => {
39
+ return vowels.test(text) ? new import_havarotjs.Text(text, { qametsQatan }).text : text;
40
+ };
41
+
42
+ // src/rules.ts
43
+ var import_cluster = require("havarotjs/dist/cluster");
44
+
45
+ // src/hebCharsTrans.ts
46
+ var transliterateMap = {
47
+ "\u05B0": "VOCAL_SHEVA",
48
+ "\u05B1": "HATAF_SEGOL",
49
+ "\u05B2": "HATAF_PATAH",
50
+ "\u05B3": "HATAF_QAMATS",
51
+ "\u05B4": "HIRIQ",
52
+ "\u05B5": "TSERE",
53
+ "\u05B6": "SEGOL",
54
+ "\u05B7": "PATAH",
55
+ "\u05B8": "QAMATS",
56
+ "\u05B9": "HOLAM",
57
+ "\u05BA": "HOLAM",
58
+ "\u05BB": "QUBUTS",
59
+ "\u05BC": "DAGESH",
60
+ "\u05BE": "MAQAF",
61
+ "\u05C0": "PASEQ",
62
+ "\u05C3": "SOF_PASUQ",
63
+ "\u05C7": "QAMATS_QATAN",
64
+ \u05D0: "ALEF",
65
+ \u05D1: "BET",
66
+ \u05D2: "GIMEL",
67
+ \u05D3: "DALET",
68
+ \u05D4: "HE",
69
+ \u05D5: "VAV",
70
+ \u05D6: "ZAYIN",
71
+ \u05D7: "HET",
72
+ \u05D8: "TET",
73
+ \u05D9: "YOD",
74
+ \u05DA: "FINAL_KAF",
75
+ \u05DB: "KAF",
76
+ \u05DC: "LAMED",
77
+ \u05DD: "FINAL_MEM",
78
+ \u05DE: "MEM",
79
+ \u05DF: "FINAL_NUN",
80
+ \u05E0: "NUN",
81
+ \u05E1: "SAMEKH",
82
+ \u05E2: "AYIN",
83
+ \u05E3: "FINAL_PE",
84
+ \u05E4: "PE",
85
+ \u05E5: "FINAL_TSADI",
86
+ \u05E6: "TSADI",
87
+ \u05E7: "QOF",
88
+ \u05E8: "RESH",
89
+ \u05E9: "SHIN",
90
+ \u05EA: "TAV"
91
+ };
92
+
93
+ // src/mapChars.ts
94
+ var mapChars = (text, schema) => [...text].map((char) => char in transliterateMap ? schema[transliterateMap[char]] : char).join("");
95
+
96
+ // src/rules.ts
97
+ var taamim = /[\u{0590}-\u{05AF}\u{05BD}\u{05BF}]/u;
98
+ var changeElementSplit = (input, split, join) => input.split(split).join(join);
99
+ var consonantFeatures = (clusterText, syl, cluster, schema) => {
100
+ var _a;
101
+ if ((_a = schema.ADDITIONAL_FEATURES) == null ? void 0 : _a.length) {
102
+ const clusterSeqs = schema.ADDITIONAL_FEATURES.filter((s) => s.FEATURE === "cluster");
103
+ for (const seq of clusterSeqs) {
104
+ const heb = new RegExp(seq.HEBREW, "u");
105
+ if (heb.test(clusterText)) {
106
+ const sylSeq = changeElementSplit(clusterText, heb, seq.TRANSLITERATION);
107
+ return [...sylSeq].map((char) => mapChars(char, schema)).join("");
108
+ }
109
+ }
110
+ }
111
+ clusterText = cluster.hasShewa && syl.isClosed ? clusterText.replace(/\u{05B0}/u, "") : clusterText;
112
+ if (/ה\u{05BC}$/mu.test(clusterText)) {
113
+ return changeElementSplit(clusterText, /ה\u{05BC}/u, schema.HE);
114
+ }
115
+ if (syl.isFinal && !syl.isClosed) {
116
+ const furtiveChet = /\u{05D7}\u{05B7}$/mu;
117
+ if (furtiveChet.test(clusterText)) {
118
+ return changeElementSplit(clusterText, furtiveChet, "\u05B7\u05D7");
119
+ }
120
+ const furtiveAyin = /\u{05E2}\u{05B7}$/mu;
121
+ if (furtiveAyin.test(clusterText)) {
122
+ return changeElementSplit(clusterText, furtiveAyin, "\u05B7\u05E2");
123
+ }
124
+ const furtiveHe = /\u{05D4}\u{05BC}\u{05B7}$/mu;
125
+ if (furtiveHe.test(clusterText)) {
126
+ return changeElementSplit(clusterText, furtiveHe, "\u05B7\u05D4\u05BC");
127
+ }
128
+ }
129
+ const prevHasVowel = cluster.prev instanceof import_cluster.Cluster ? cluster.prev.hasVowel : false;
130
+ const isDoubled = schema.DAGESH_CHAZAQ && prevHasVowel && /\u{05BC}/u.test(clusterText);
131
+ if (schema.BET_DAGESH && /ב\u{05BC}/u.test(clusterText)) {
132
+ return changeElementSplit(clusterText, /ב\u{05BC}/u, schema.BET_DAGESH.repeat(isDoubled ? 2 : 1));
133
+ }
134
+ if (schema.GIMEL_DAGESH && /ג\u{05BC}/u.test(clusterText)) {
135
+ return changeElementSplit(clusterText, /ג\u{05BC}/u, schema.GIMEL_DAGESH.repeat(isDoubled ? 2 : 1));
136
+ }
137
+ if (schema.DALET_DAGESH && /ד\u{05BC}/u.test(clusterText)) {
138
+ return changeElementSplit(clusterText, /ד\u{05BC}/u, schema.DALET_DAGESH.repeat(isDoubled ? 2 : 1));
139
+ }
140
+ if (schema.KAF_DAGESH && /כ\u{05BC}/u.test(clusterText)) {
141
+ return changeElementSplit(clusterText, /כ\u{05BC}/u, schema.KAF_DAGESH.repeat(isDoubled ? 2 : 1));
142
+ }
143
+ if (schema.KAF_DAGESH && /ך\u{05BC}/u.test(clusterText)) {
144
+ return changeElementSplit(clusterText, /ך\u{05BC}/u, schema.KAF_DAGESH.repeat(isDoubled ? 2 : 1));
145
+ }
146
+ if (schema.PE_DAGESH && /פ\u{05BC}/u.test(clusterText)) {
147
+ return changeElementSplit(clusterText, /פ\u{05BC}/u, schema.PE_DAGESH.repeat(isDoubled ? 2 : 1));
148
+ }
149
+ if (schema.TAV_DAGESH && /ת\u{05BC}/u.test(clusterText)) {
150
+ return changeElementSplit(clusterText, /ת\u{05BC}/u, schema.TAV_DAGESH.repeat(isDoubled ? 2 : 1));
151
+ }
152
+ if (/ש\u{05C1}/u.test(clusterText)) {
153
+ return changeElementSplit(clusterText, /ש\u{05C1}/u, schema.SHIN.repeat(isDoubled ? 2 : 1));
154
+ }
155
+ if (/ש\u{05C2}/u.test(clusterText)) {
156
+ return changeElementSplit(clusterText, /ש\u{05C2}/u, schema.SIN.repeat(isDoubled ? 2 : 1));
157
+ }
158
+ if (isDoubled) {
159
+ const consonant = cluster.chars[0].text;
160
+ const consonantDagesh = new RegExp(consonant + "\u05BC", "u");
161
+ return changeElementSplit(clusterText, consonantDagesh, `${consonant + consonant}`);
162
+ }
163
+ if (cluster.isShureq) {
164
+ return schema.SHUREQ;
165
+ }
166
+ return clusterText;
167
+ };
168
+ var materFeatures = (syl, schema) => {
169
+ const mater = syl.clusters.filter((c) => c.isMater)[0];
170
+ const prev = mater.prev instanceof import_cluster.Cluster ? mater.prev : null;
171
+ const materText = mater.text;
172
+ const prevText = ((prev == null ? void 0 : prev.text) || "").replace(taamim, "");
173
+ let noMaterText = syl.clusters.filter((c) => !c.isMater).map((c) => consonantFeatures(c.text.replace(taamim, ""), syl, c, schema)).join("");
174
+ const hasMaqaf = mater.text.includes("\u05BE");
175
+ noMaterText = hasMaqaf ? noMaterText.concat("\u05BE") : noMaterText;
176
+ if (/י/.test(materText)) {
177
+ if (/\u{05B4}/u.test(prevText)) {
178
+ return changeElementSplit(noMaterText, /\u{05B4}/u, schema.HIRIQ_YOD);
179
+ }
180
+ if (/\u{05B5}/u.test(prevText)) {
181
+ return changeElementSplit(noMaterText, /\u{05B5}/u, schema.TSERE_YOD);
182
+ }
183
+ if (/\u{05B6}/u.test(prevText)) {
184
+ return changeElementSplit(noMaterText, /\u{05B6}/u, schema.SEGOL_YOD);
185
+ }
186
+ }
187
+ if (/ו/u.test(materText)) {
188
+ if (/\u{05B9}/u.test(prevText)) {
189
+ return changeElementSplit(noMaterText, /\u{05B9}/u, schema.HOLAM_VAV);
190
+ }
191
+ }
192
+ if (/ה/.test(materText)) {
193
+ if (/\u{05B8}/u.test(prevText)) {
194
+ return changeElementSplit(noMaterText, /\u{05B8}/u, schema.QAMATS_HE);
195
+ }
196
+ if (/\u{05B6}/u.test(prevText)) {
197
+ return changeElementSplit(noMaterText, /\u{05B6}/u, schema.SEGOL_HE);
198
+ }
199
+ if (/\u{05B5}/u.test(prevText)) {
200
+ return changeElementSplit(noMaterText, /\u{05B5}/u, schema.SEGOL_HE);
201
+ }
202
+ }
203
+ return materText;
204
+ };
205
+ var joinChars = (isAccented, sylChars, schema) => {
206
+ if (!isAccented) {
207
+ return sylChars.map((char) => mapChars(char, schema)).join("");
208
+ }
209
+ if (schema.STRESS_MARKER) {
210
+ const location = schema.STRESS_MARKER.location;
211
+ const mark = schema.STRESS_MARKER.mark;
212
+ if (location === "before-syllable") {
213
+ return `${mark}${sylChars.map((char) => mapChars(char, schema)).join("")}`;
214
+ }
215
+ if (location === "after-syllable") {
216
+ return `${sylChars.map((char) => mapChars(char, schema)).join("")}${mark}`;
217
+ }
218
+ const vowels3 = [
219
+ schema.PATAH,
220
+ schema.HATAF_PATAH,
221
+ schema.QAMATS,
222
+ schema.HATAF_QAMATS,
223
+ schema.SEGOL,
224
+ schema.HATAF_SEGOL,
225
+ schema.TSERE,
226
+ schema.HIRIQ,
227
+ schema.HOLAM,
228
+ schema.QAMATS_QATAN,
229
+ schema.QUBUTS,
230
+ schema.QAMATS_HE,
231
+ schema.SEGOL_HE,
232
+ schema.TSERE_HE,
233
+ schema.HIRIQ_YOD,
234
+ schema.TSERE_YOD,
235
+ schema.SEGOL_YOD,
236
+ schema.HOLAM_VAV,
237
+ schema.SHUREQ
238
+ ].sort((a, b) => b.length - a.length);
239
+ const vowelRgx = new RegExp(`${vowels3.join("|")}`);
240
+ const str = sylChars.map((char) => mapChars(char, schema)).join("");
241
+ const match = str.match(vowelRgx);
242
+ if (location === "before-vowel") {
243
+ return (match == null ? void 0 : match.length) ? str.replace(match[0], `${mark}${match[0]}`) : str;
244
+ }
245
+ return (match == null ? void 0 : match.length) ? str.replace(match[0], `${match[0]}${mark}`) : str;
246
+ }
247
+ return sylChars.map((char) => mapChars(char, schema)).join("");
248
+ };
249
+ var sylRules = (syl, schema) => {
250
+ var _a;
251
+ const sylTxt = syl.text.replace(taamim, "");
252
+ if ((_a = schema.ADDITIONAL_FEATURES) == null ? void 0 : _a.length) {
253
+ const sylSeqs = schema.ADDITIONAL_FEATURES.filter((s) => s.FEATURE === "syllable");
254
+ for (const seq of sylSeqs) {
255
+ const heb = new RegExp(seq.HEBREW, "u");
256
+ if (heb.test(sylTxt)) {
257
+ const wordSeq = changeElementSplit(sylTxt, heb, seq.TRANSLITERATION);
258
+ return joinChars(syl.isAccented, [...wordSeq], schema);
259
+ }
260
+ }
261
+ }
262
+ const mSSuffix = /\u{05B8}\u{05D9}\u{05D5}/u;
263
+ if (syl.isFinal && mSSuffix.test(sylTxt)) {
264
+ const sufxSyl = changeElementSplit(sylTxt, mSSuffix, schema.MS_SUFX);
265
+ return joinChars(syl.isAccented, [...sufxSyl], schema);
266
+ }
267
+ const hasMater = syl.clusters.map((c) => c.isMater).includes(true);
268
+ if (hasMater) {
269
+ const materSyl = materFeatures(syl, schema);
270
+ return joinChars(syl.isAccented, [...materSyl], schema);
271
+ }
272
+ const returnTxt = syl.clusters.map((cluster) => {
273
+ const clusterText = cluster.text.replace(taamim, "");
274
+ return consonantFeatures(clusterText, syl, cluster, schema);
275
+ });
276
+ return joinChars(syl.isAccented, returnTxt, schema);
277
+ };
278
+ var wordRules = (word, schema) => {
279
+ var _a;
280
+ if (word.isDivineName)
281
+ return schema.DIVINE_NAME;
282
+ if (word.hasDivineName)
283
+ return `${sylRules(word.syllables[0], schema)}-${schema.DIVINE_NAME}`;
284
+ if ((_a = schema.ADDITIONAL_FEATURES) == null ? void 0 : _a.length) {
285
+ const wordSeqs = schema.ADDITIONAL_FEATURES.filter((s) => s.FEATURE === "word");
286
+ for (const seq of wordSeqs) {
287
+ const heb = new RegExp(seq.HEBREW, "u");
288
+ const wordText = word.text.replace(taamim, "");
289
+ if (heb.test(wordText)) {
290
+ const wordSeq = changeElementSplit(wordText, heb, seq.TRANSLITERATION);
291
+ return [...wordSeq].map((char) => mapChars(char, schema)).join("");
292
+ }
293
+ }
294
+ }
295
+ return word;
296
+ };
297
+
298
+ // src/schema.ts
299
+ var Schema = class {
300
+ constructor(schema) {
301
+ 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;
302
+ }
303
+ };
304
+ var SBL = class extends Schema {
305
+ constructor(schema) {
306
+ super({
307
+ VOCAL_SHEVA: schema.VOCAL_SHEVA || "\u01DD",
308
+ HATAF_SEGOL: schema.HATAF_SEGOL || "\u0115",
309
+ HATAF_PATAH: schema.HATAF_PATAH || "\u0103",
310
+ HATAF_QAMATS: schema.HATAF_QAMATS || "\u014F",
311
+ HIRIQ: schema.HIRIQ || "i",
312
+ TSERE: schema.TSERE || "\u0113",
313
+ SEGOL: schema.SEGOL || "e",
314
+ PATAH: schema.PATAH || "a",
315
+ QAMATS: schema.QAMATS || "\u0101",
316
+ HOLAM: schema.HOLAM || "\u014D",
317
+ QUBUTS: schema.QUBUTS || "\u016B",
318
+ DAGESH: schema.DAGESH || "",
319
+ DAGESH_CHAZAQ: (_a = schema.DAGESH_CHAZAQ) != null ? _a : true,
320
+ MAQAF: schema.MAQAF || "-",
321
+ PASEQ: schema.PASEQ || "",
322
+ SOF_PASUQ: schema.SOF_PASUQ || "",
323
+ QAMATS_QATAN: schema.QAMATS_QATAN || "o",
324
+ FURTIVE_PATAH: schema.FURTIVE_PATAH || "a",
325
+ HIRIQ_YOD: schema.HIRIQ_YOD || "\xEE",
326
+ TSERE_YOD: schema.TSERE_YOD || "\xEA",
327
+ SEGOL_YOD: schema.SEGOL_YOD || "\xEA",
328
+ SHUREQ: schema.SHUREQ || "\xFB",
329
+ HOLAM_VAV: schema.HOLAM_VAV || "\xF4",
330
+ QAMATS_HE: schema.QAMATS_HE || "\xE2",
331
+ SEGOL_HE: schema.SEGOL_HE || "\xEA",
332
+ TSERE_HE: schema.TSERE_HE || "\xEA",
333
+ MS_SUFX: schema.MS_SUFX || "\u0101yw",
334
+ ALEF: schema.ALEF || "\u02BE",
335
+ BET: schema.BET || "b",
336
+ BET_DAGESH: schema.BET_DAGESH || void 0,
337
+ GIMEL: schema.GIMEL || "g",
338
+ GIMEL_DAGESH: schema.GIMEL_DAGESH || void 0,
339
+ DALET: schema.DALET || "d",
340
+ DALET_DAGESH: schema.DALET_DAGESH || void 0,
341
+ HE: schema.HE || "h",
342
+ VAV: schema.VAV || "w",
343
+ ZAYIN: schema.ZAYIN || "z",
344
+ HET: schema.HET || "\u1E25",
345
+ TET: schema.TET || "\u1E6D",
346
+ YOD: schema.YOD || "y",
347
+ FINAL_KAF: schema.FINAL_KAF || "k",
348
+ KAF: schema.KAF || "k",
349
+ KAF_DAGESH: schema.KAF_DAGESH || void 0,
350
+ LAMED: schema.LAMED || "l",
351
+ FINAL_MEM: schema.FINAL_MEM || "m",
352
+ MEM: schema.MEM || "m",
353
+ FINAL_NUN: schema.FINAL_NUN || "n",
354
+ NUN: schema.NUN || "n",
355
+ SAMEKH: schema.SAMEKH || "s",
356
+ AYIN: schema.AYIN || "\u02BF",
357
+ FINAL_PE: schema.FINAL_PE || "p",
358
+ PE: schema.PE || "p",
359
+ PE_DAGESH: schema.PE_DAGESH || void 0,
360
+ FINAL_TSADI: schema.FINAL_TSADI || "\u1E63",
361
+ TSADI: schema.TSADI || "\u1E63",
362
+ QOF: schema.QOF || "q",
363
+ RESH: schema.RESH || "r",
364
+ SHIN: schema.SHIN || "\u0161",
365
+ SIN: schema.SIN || "\u015B",
366
+ TAV: schema.TAV || "t",
367
+ TAV_DAGESH: schema.TAV_DAGESH || void 0,
368
+ DIVINE_NAME: schema.DIVINE_NAME || "yhwh",
369
+ SYLLABLE_SEPARATOR: schema.SYLLABLE_SEPARATOR || void 0,
370
+ ADDITIONAL_FEATURES: schema.ADDITIONAL_FEATURES || void 0,
371
+ STRESS_MARKER: schema.STRESS_MARKER || void 0,
372
+ longVowels: (_b = schema.longVowels) != null ? _b : true,
373
+ qametsQatan: (_c = schema.qametsQatan) != null ? _c : true,
374
+ sqnmlvy: (_d = schema.sqnmlvy) != null ? _d : true,
375
+ wawShureq: (_e = schema.wawShureq) != null ? _e : true,
376
+ article: (_f = schema.article) != null ? _f : true
377
+ });
378
+ var _a, _b, _c, _d, _e, _f;
379
+ }
380
+ };
381
+
382
+ // src/transliterate.ts
383
+ var import_havarotjs2 = require("havarotjs");
384
+ var import_word = require("havarotjs/dist/word");
385
+ var getSylOpts = (schema) => {
386
+ const options = {};
387
+ if ("longVowels" in schema)
388
+ options.longVowels = schema.longVowels;
389
+ if ("qametsQatan" in schema)
390
+ options.qametsQatan = schema.qametsQatan;
391
+ if ("sqnmlvy" in schema)
392
+ options.sqnmlvy = schema.sqnmlvy;
393
+ if ("wawShureq" in schema)
394
+ options.wawShureq = schema.wawShureq;
395
+ if ("article" in schema)
396
+ options.article = schema.article;
397
+ return options;
398
+ };
399
+ var transliterate = (text, schema) => {
400
+ const transSchema = schema instanceof Schema ? schema : new SBL(schema != null ? schema : {});
401
+ const isText = text instanceof import_havarotjs2.Text;
402
+ if (!isText && !vowels.test(text))
403
+ return mapChars(text, transSchema);
404
+ const sylOptions = getSylOpts(transSchema != null ? transSchema : {});
405
+ const newText = isText ? text : new import_havarotjs2.Text(text, sylOptions);
406
+ return newText.words.map((word) => {
407
+ var _a, _b;
408
+ let transliteration = wordRules(word, transSchema);
409
+ if (transliteration instanceof import_word.Word) {
410
+ transliteration = word.syllables.map((s) => sylRules(s, transSchema)).join((_a = transSchema.SYLLABLE_SEPARATOR) != null ? _a : "");
411
+ }
412
+ return `${transliteration}${(_b = word.whiteSpaceAfter) != null ? _b : ""}`;
413
+ }).join("");
414
+ };
415
+
416
+ // src/remove.ts
417
+ var cantillation = /[\u{0591}-\u{05AF}\u{05BF}\u{05C0}\u{05C3}-\u{05C6}\u{05F3}\u{05F4}]/gu;
418
+ var vowels2 = /[\u{05B0}-\u{05BD}\u{05BF}\u{05C7}]/gu;
419
+ var shinDot = /\u{05C1}/gu;
420
+ var sinDot = /\u{05C2}/gu;
421
+ var removeItem = (text, item) => text.replace(item, "");
422
+ var remove = (text, { removeVowels = false, removeShinDot = false, removeSinDot = false } = {}) => {
423
+ const sequenced = sequence(text);
424
+ const remCantillation = removeItem(sequenced, cantillation);
425
+ const remVowels = removeVowels ? removeItem(remCantillation, vowels2) : remCantillation;
426
+ const remShin = removeShinDot ? removeItem(remVowels, shinDot) : remVowels;
427
+ return removeSinDot ? removeItem(remShin, sinDot) : remShin;
428
+ };
429
+ module.exports = __toCommonJS(src_exports);
430
+ // Annotate the CommonJS export names for ESM import in node:
431
+ 0 && (module.exports = {
432
+ Schema,
433
+ Text,
434
+ remove,
435
+ sequence,
436
+ transliterate
437
+ });
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "hebrew-transliteration",
3
- "version": "2.0.0",
4
- "description": "a package for transliterating Hebrew according to SBL guidelines",
5
- "main": "./dist/index.js",
6
- "types": "./dist/index.d.ts",
3
+ "version": "2.0.3",
4
+ "description": "a package for transliterating Hebrew",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "module": "dist/indes.esm.js",
7
8
  "scripts": {
8
- "build": "tsc",
9
+ "build": "node build.js",
9
10
  "test": "clear && jest",
10
11
  "format": "prettier --write 'src/**/*.ts' 'test/**/*.ts'",
11
12
  "lint": "eslint . --ext .ts",
@@ -36,20 +37,22 @@
36
37
  "author": "Charles Loder",
37
38
  "license": "MIT",
38
39
  "devDependencies": {
39
- "@types/jest": "^27.0.3",
40
- "@typescript-eslint/eslint-plugin": "^5.6.0",
41
- "eslint": "^8.4.0",
42
- "eslint-config-prettier": "^8.3.0",
43
- "eslint-plugin-jest": "^25.3.0",
44
- "eslint-plugin-jsdoc": "^37.1.0",
40
+ "@types/jest": "^27.4.1",
41
+ "@typescript-eslint/eslint-plugin": "^5.13.0",
42
+ "esbuild": "^0.14.25",
43
+ "eslint": "^8.10.0",
44
+ "eslint-config-prettier": "^8.5.0",
45
+ "eslint-plugin-jest": "^26.1.1",
46
+ "eslint-plugin-jsdoc": "^37.9.6",
45
47
  "eslint-plugin-prefer-arrow": "^1.2.3",
46
- "jest": "^27.4.3",
47
- "npm-check-updates": "^12.0.3",
48
+ "jest": "^27.5.1",
49
+ "npm-check-updates": "^12.5.2",
50
+ "npm-dts": "^1.3.11",
48
51
  "prettier": "^2.5.1",
49
- "ts-jest": "^27.1.0",
50
- "typescript": "^4.5.2"
52
+ "ts-jest": "^27.1.3",
53
+ "typescript": "^4.6.2"
51
54
  },
52
55
  "dependencies": {
53
- "havarotjs": "^0.7.2"
56
+ "havarotjs": "^0.7.3"
54
57
  }
55
58
  }
package/LICENSE DELETED
@@ -1,7 +0,0 @@
1
- Copyright 2019 Charles Loder
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
-
5
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,6 +0,0 @@
1
- import { Schema } from "./schema";
2
- interface map {
3
- [k: string]: keyof Schema;
4
- }
5
- export declare const transliterateMap: map;
6
- export {};
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transliterateMap = void 0;
4
- exports.transliterateMap = {
5
- // niqqud
6
- "\u{05B0}": "VOCAL_SHEVA",
7
- "\u{05B1}": "HATAF_SEGOL",
8
- "\u{05B2}": "HATAF_PATAH",
9
- "\u{05B3}": "HATAF_QAMATS",
10
- "\u{05B4}": "HIRIQ",
11
- "\u{05B5}": "TSERE",
12
- "\u{05B6}": "SEGOL",
13
- "\u{05B7}": "PATAH",
14
- "\u{05B8}": "QAMATS",
15
- "\u{05B9}": "HOLAM",
16
- "\u{05BA}": "HOLAM",
17
- "\u{05BB}": "QUBUTS",
18
- "\u{05BC}": "DAGESH",
19
- // "\u{05BD}": "", // HEBREW POINT METEG (U+05BD)
20
- "\u{05BE}": "MAQAF",
21
- "\u{05C0}": "PASEQ",
22
- "\u{05C3}": "SOF_PASUQ",
23
- "\u{05C7}": "QAMATS_QATAN",
24
- // consonants
25
- א: "ALEF",
26
- ב: "BET",
27
- ג: "GIMEL",
28
- ד: "DALET",
29
- ה: "HE",
30
- ו: "VAV",
31
- ז: "ZAYIN",
32
- ח: "HET",
33
- ט: "TET",
34
- י: "YOD",
35
- ך: "FINAL_KAF",
36
- כ: "KAF",
37
- ל: "LAMED",
38
- ם: "FINAL_MEM",
39
- מ: "MEM",
40
- ן: "FINAL_NUN",
41
- נ: "NUN",
42
- ס: "SAMEKH",
43
- ע: "AYIN",
44
- ף: "FINAL_PE",
45
- פ: "PE",
46
- ץ: "FINAL_TSADI",
47
- צ: "TSADI",
48
- ק: "QOF",
49
- ר: "RESH",
50
- ש: "SHIN",
51
- ת: "TAV" // HEBREW LETTER TAV (U+05EA)
52
- // "\u{05EF}": "", // HEBREW YOD TRIANGLE (U+05EF)
53
- // װ: "", // HEBREW LIGATURE YIDDISH DOUBLE VAV (U+05F0)
54
- // ױ: "", // HEBREW LIGATURE YIDDISH VAV YOD (U+05F1)
55
- // ײ: "" // HEBREW LIGATURE YIDDISH DOUBLE YOD (U+05F2)
56
- };
57
- //# sourceMappingURL=hebCharsTrans.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hebCharsTrans.js","sourceRoot":"","sources":["../src/hebCharsTrans.ts"],"names":[],"mappings":";;;AAMa,QAAA,gBAAgB,GAAQ;IACnC,WAAW;IACX,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,cAAc;IAC1B,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,QAAQ;IACpB,kDAAkD;IAClD,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE,WAAW;IACvB,UAAU,EAAE,cAAc;IAC1B,eAAe;IACf,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,WAAW;IACd,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,WAAW;IACd,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,WAAW;IACd,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,QAAQ;IACX,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,UAAU;IACb,CAAC,EAAE,IAAI;IACP,CAAC,EAAE,aAAa;IAChB,CAAC,EAAE,OAAO;IACV,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,MAAM;IACT,CAAC,EAAE,KAAK,CAAC,6BAA6B;IACtC,kDAAkD;IAClD,wDAAwD;IACxD,qDAAqD;IACrD,uDAAuD;CACxD,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAME,qFAN1B,gBAAI,OAM0B;AALvC,mDAAgD;AAKP,8FALhC,6BAAa,OAKgC;AAJtD,yCAAsC;AAIb,yFAJhB,mBAAQ,OAIgB;AAHjC,qCAAkC;AAGzB,uFAHA,eAAM,OAGA;AAFf,qCAAkC;AAEjB,uFAFR,eAAM,OAEQ"}