hebrew-transliteration 1.3.1 → 2.0.2

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,24 +1,437 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sequence = exports.remove = exports.transliterate = void 0;
4
- var transliterate_1 = require("./transliterate");
5
- var sequence_1 = require("./sequence");
6
- var remove_1 = require("./remove");
7
- exports.transliterate = function (text, _a) {
8
- var _b = _a === void 0 ? {} : _a, _c = _b.isSequenced, isSequenced = _c === void 0 ? true : _c, _d = _b.qametsQatan, qametsQatan = _d === void 0 ? false : _d, _e = _b.isSimple, isSimple = _e === void 0 ? false : _e;
9
- var normalized = text.normalize("NFKD");
10
- return transliterate_1.Transliterate(normalized, { isSequenced: isSequenced, qametsQatan: qametsQatan, isSimple: isSimple });
11
- };
12
- exports.remove = function (text, _a) {
13
- var _b = _a === void 0 ? {} : _a, _c = _b.removeVowels, removeVowels = _c === void 0 ? false : _c, _d = _b.removeShinDot, removeShinDot = _d === void 0 ? false : _d, _e = _b.removeSinDot, removeSinDot = _e === void 0 ? false : _e;
14
- var normalized = text.normalize("NFKD");
15
- var removed = remove_1.Remove(normalized, { removeVowels: removeVowels, removeShinDot: removeShinDot, removeSinDot: removeSinDot });
16
- var noMetheg = removed.replace(/\u{05BD}/gu, "");
17
- var sequenced = sequence_1.Sequence(noMetheg);
18
- return sequenced;
19
- };
20
- exports.sequence = function (text) {
21
- var normalized = text.normalize("NFKD");
22
- return sequence_1.Sequence(normalized);
23
- };
24
- //# 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,19 +1,21 @@
1
1
  {
2
2
  "name": "hebrew-transliteration",
3
- "version": "1.3.1",
3
+ "version": "2.0.2",
4
4
  "description": "a package for transliterating Hebrew according to SBL guidelines",
5
- "main": "./dist/index.js",
6
- "types": "./dist/index.d.ts",
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
- "lint": "tslint -p tsconfig.json",
12
+ "lint": "eslint . --ext .ts",
12
13
  "prepare": "npm run build",
13
14
  "prepublishOnly": "npm test && npm run lint",
14
15
  "preversion": "npm run lint",
15
16
  "version": "npm run format && git add -A src",
16
- "postversion": "git push && git push --tags"
17
+ "postversion": "git push && git push --tags",
18
+ "updates": "ncu"
17
19
  },
18
20
  "files": [
19
21
  "dist/**/*"
@@ -35,12 +37,22 @@
35
37
  "author": "Charles Loder",
36
38
  "license": "MIT",
37
39
  "devDependencies": {
38
- "@types/jest": "^25.2.1",
39
- "jest": "^25.4.0",
40
- "prettier": "^2.0.5",
41
- "ts-jest": "^25.4.0",
42
- "tslint": "^6.1.1",
43
- "tslint-config-prettier": "^1.18.0",
44
- "typescript": "^3.8.3"
40
+ "@types/jest": "^27.4.0",
41
+ "@typescript-eslint/eslint-plugin": "^5.10.2",
42
+ "esbuild": "^0.14.18",
43
+ "eslint": "^8.8.0",
44
+ "eslint-config-prettier": "^8.3.0",
45
+ "eslint-plugin-jest": "^26.0.0",
46
+ "eslint-plugin-jsdoc": "^37.7.1",
47
+ "eslint-plugin-prefer-arrow": "^1.2.3",
48
+ "jest": "^27.4.7",
49
+ "npm-check-updates": "^12.2.1",
50
+ "npm-dts": "^1.3.11",
51
+ "prettier": "^2.5.1",
52
+ "ts-jest": "^27.1.3",
53
+ "typescript": "^4.5.5"
54
+ },
55
+ "dependencies": {
56
+ "havarotjs": "^0.7.2"
45
57
  }
46
58
  }
@@ -1,2 +0,0 @@
1
- import { Dict } from "./interfaces";
2
- export declare const transliterateMap: Dict;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transliterateMap = void 0;
4
- exports.transliterateMap = {
5
- // niqqud
6
- "\u05B0": "ǝ",
7
- "\u05B1": "ĕ",
8
- "\u05B2": "ă",
9
- "\u05B3": "ŏ",
10
- "\u05B4": "i",
11
- "\u05B5": "ē",
12
- "\u05B6": "e",
13
- "\u05B7": "a",
14
- "\u05B8": "ā",
15
- "\u05B9": "ō",
16
- "\u05BA": "ō",
17
- "\u05BB": "u",
18
- // "\u{05BC}": "", // HEBREW POINT DAGESH OR MAPIQ (U+05BC)
19
- // "\u{05BD}": "", // HEBREW POINT METEG (U+05BD)
20
- "\u05BE": "-",
21
- "\u05C7": "ο",
22
- // consonants
23
- א: "ʾ",
24
- ב: "b",
25
- ג: "g",
26
- ד: "d",
27
- ה: "h",
28
- ו: "w",
29
- ז: "z",
30
- ח: "ḥ",
31
- ט: "ṭ",
32
- י: "y",
33
- ך: "k",
34
- כ: "k",
35
- ל: "l",
36
- ם: "m",
37
- מ: "m",
38
- ן: "n",
39
- נ: "n",
40
- ס: "s",
41
- ע: "ʿ",
42
- ף: "p",
43
- פ: "p",
44
- ץ: "ṣ",
45
- צ: "ṣ",
46
- ק: "q",
47
- ר: "r",
48
- ש: "š",
49
- ת: "t",
50
- "\u05EF": "",
51
- װ: "",
52
- ױ: "",
53
- ײ: "" // HEBREW LIGATURE YIDDISH DOUBLE YOD (U+05F2)
54
- };
55
- //# sourceMappingURL=hebCharsTrans.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hebCharsTrans.js","sourceRoot":"","sources":["../src/hebCharsTrans.ts"],"names":[],"mappings":";;;AAEa,QAAA,gBAAgB,GAAS;IACpC,WAAW;IACX,QAAU,EAAE,GAAG;IACf,QAAU,EAAE,GAAG;IACf,QAAU,EAAE,GAAG;IACf,QAAU,EAAE,GAAG;IACf,QAAU,EAAE,GAAG;IACf,QAAU,EAAE,GAAG;IACf,QAAU,EAAE,GAAG;IACf,QAAU,EAAE,GAAG;IACf,QAAU,EAAE,GAAG;IACf,QAAU,EAAE,GAAG;IACf,QAAU,EAAE,GAAG;IACf,QAAU,EAAE,GAAG;IACf,4DAA4D;IAC5D,kDAAkD;IAClD,QAAU,EAAE,GAAG;IACf,QAAU,EAAE,GAAG;IACf,eAAe;IACf,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,QAAU,EAAE,EAAE;IACd,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE;IACL,CAAC,EAAE,EAAE,CAAC,8CAA8C;CACrD,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AACA,iDAAgD;AAChD,uCAAsC;AACtC,mCAAkC;AAErB,QAAA,aAAa,GAAG,UAC3B,IAAY,EACZ,EAAgF;QAAhF,qBAA8E,EAAE,KAAA,EAA9E,mBAAkB,EAAlB,WAAW,mBAAG,IAAI,KAAA,EAAE,mBAAmB,EAAnB,WAAW,mBAAG,KAAK,KAAA,EAAE,gBAAgB,EAAhB,QAAQ,mBAAG,KAAK,KAAA;IAE3D,IAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,6BAAa,CAAC,UAAU,EAAE,EAAE,WAAW,aAAA,EAAE,WAAW,aAAA,EAAE,QAAQ,UAAA,EAAE,CAAC,CAAC;AAC3E,CAAC,CAAC;AAEW,QAAA,MAAM,GAAG,UACpB,IAAY,EACZ,EAAyF;QAAzF,qBAAuF,EAAE,KAAA,EAAvF,oBAAoB,EAApB,YAAY,mBAAG,KAAK,KAAA,EAAE,qBAAqB,EAArB,aAAa,mBAAG,KAAK,KAAA,EAAE,oBAAoB,EAApB,YAAY,mBAAG,KAAK,KAAA;IAEnE,IAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1C,IAAM,OAAO,GAAG,eAAM,CAAC,UAAU,EAAE,EAAE,YAAY,cAAA,EAAE,aAAa,eAAA,EAAE,YAAY,cAAA,EAAE,CAAC,CAAC;IAClF,IAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IACnD,IAAM,SAAS,GAAG,mBAAQ,CAAC,QAAQ,CAAC,CAAC;IACrC,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEW,QAAA,QAAQ,GAAG,UAAC,IAAY;IACnC,IAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC1C,OAAO,mBAAQ,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC,CAAC"}
@@ -1,13 +0,0 @@
1
- export interface TransOptions {
2
- isSequenced?: boolean;
3
- qametsQatan?: boolean;
4
- isSimple?: boolean;
5
- }
6
- export interface RemoveOptions {
7
- removeVowels?: boolean;
8
- removeShinDot?: boolean;
9
- removeSinDot?: boolean;
10
- }
11
- export interface Dict {
12
- [key: string]: string;
13
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=interfaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- export declare const qametsQ: (text: string[]) => string[];