@hebcal/leyning 8.2.5 → 8.2.7
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/bundle.js +84 -45
- package/dist/bundle.min.js +2 -2
- package/dist/index.cjs +84 -45
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +84 -45
- package/dist/module.d.ts +316 -0
- package/package.json +10 -9
package/dist/bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/leyning v8.2.
|
|
1
|
+
/*! @hebcal/leyning v8.2.7 */
|
|
2
2
|
var hebcal__leyning = (function (exports, core) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -54,7 +54,14 @@ var numverses = {
|
|
|
54
54
|
* Names of the books of the Torah. BOOK[1] === 'Genesis'
|
|
55
55
|
* @readonly
|
|
56
56
|
*/
|
|
57
|
-
const BOOK = [
|
|
57
|
+
const BOOK = [
|
|
58
|
+
'',
|
|
59
|
+
'Genesis',
|
|
60
|
+
'Exodus',
|
|
61
|
+
'Leviticus',
|
|
62
|
+
'Numbers',
|
|
63
|
+
'Deuteronomy',
|
|
64
|
+
];
|
|
58
65
|
/**
|
|
59
66
|
* Formats parsha as a string
|
|
60
67
|
* @param parsha untranslated name like 'Pinchas' or ['Pinchas'] or ['Matot','Masei']
|
|
@@ -63,7 +70,9 @@ function parshaToString(parsha) {
|
|
|
63
70
|
if (typeof parsha === 'string') {
|
|
64
71
|
return parsha;
|
|
65
72
|
}
|
|
66
|
-
else if (!Array.isArray(parsha) ||
|
|
73
|
+
else if (!Array.isArray(parsha) ||
|
|
74
|
+
parsha.length === 0 ||
|
|
75
|
+
parsha.length > 2) {
|
|
67
76
|
throw new TypeError(`Bad parsha argument: ${parsha}`);
|
|
68
77
|
}
|
|
69
78
|
let s = parsha[0];
|
|
@@ -130,16 +139,16 @@ function formatAliyahShort(aliyah, showBook) {
|
|
|
130
139
|
* @private
|
|
131
140
|
*/
|
|
132
141
|
function isChapVerseBefore(a, b) {
|
|
133
|
-
const cv1 = a.split(':').map(
|
|
134
|
-
const cv2 = b.split(':').map(
|
|
135
|
-
return
|
|
142
|
+
const cv1 = a.split(':').map(x => +x);
|
|
143
|
+
const cv2 = b.split(':').map(x => +x);
|
|
144
|
+
return cv1[0] * 100 + cv1[1] < cv2[0] * 100 + cv2[1];
|
|
136
145
|
}
|
|
137
146
|
/**
|
|
138
147
|
* Summarizes an `AliyotMap` by collapsing all adjacent aliyot.
|
|
139
148
|
* Finds any non-overlapping parts (e.g. special 7th aliyah or maftir)
|
|
140
149
|
*/
|
|
141
150
|
function makeLeyningParts(aliyot) {
|
|
142
|
-
const nums = Object.keys(aliyot).filter(
|
|
151
|
+
const nums = Object.keys(aliyot).filter(x => {
|
|
143
152
|
if (x.length === 1) {
|
|
144
153
|
return true;
|
|
145
154
|
}
|
|
@@ -152,15 +161,17 @@ function makeLeyningParts(aliyot) {
|
|
|
152
161
|
for (let i = 0; i < nums.length; i++) {
|
|
153
162
|
const num = nums[i];
|
|
154
163
|
const aliyah = aliyot[num];
|
|
155
|
-
if (
|
|
164
|
+
if (i === nums.length - 1 && aliyah.k === end.k && aliyah.e === end.e) {
|
|
156
165
|
// short-circuit when final aliyah is within the previous (e.g. M inside of 7)
|
|
157
166
|
continue;
|
|
158
167
|
}
|
|
159
|
-
const prevEndChap = +
|
|
160
|
-
const curStartChap = +
|
|
168
|
+
const prevEndChap = +end.e.split(':')[0];
|
|
169
|
+
const curStartChap = +aliyah.b.split(':')[0];
|
|
161
170
|
const sameOrNextChap = curStartChap === prevEndChap || curStartChap === prevEndChap + 1;
|
|
162
|
-
if (
|
|
163
|
-
(aliyah.k !== start.k ||
|
|
171
|
+
if (i !== 0 &&
|
|
172
|
+
(aliyah.k !== start.k ||
|
|
173
|
+
isChapVerseBefore(aliyah.b, start.e) ||
|
|
174
|
+
!sameOrNextChap)) {
|
|
164
175
|
parts.push({ k: start.k, b: start.b, e: end.e });
|
|
165
176
|
start = aliyah;
|
|
166
177
|
}
|
|
@@ -226,7 +237,9 @@ function cloneHaftara(haft) {
|
|
|
226
237
|
* Returns the total number of verses in an array of Aliyah (or haftarah) objects
|
|
227
238
|
*/
|
|
228
239
|
function sumVerses(aliyot) {
|
|
229
|
-
return Array.isArray(aliyot)
|
|
240
|
+
return Array.isArray(aliyot)
|
|
241
|
+
? aliyot.reduce((prev, cur) => prev + cur.v, 0)
|
|
242
|
+
: aliyot.v;
|
|
230
243
|
}
|
|
231
244
|
|
|
232
245
|
var festivals0 = { "Pesach I": {
|
|
@@ -881,9 +894,15 @@ function lookupFestival(holiday) {
|
|
|
881
894
|
return result;
|
|
882
895
|
}
|
|
883
896
|
|
|
884
|
-
const HOLIDAY_IGNORE_MASK = core.flags.DAF_YOMI |
|
|
885
|
-
core.flags.
|
|
886
|
-
core.flags.
|
|
897
|
+
const HOLIDAY_IGNORE_MASK = core.flags.DAF_YOMI |
|
|
898
|
+
core.flags.OMER_COUNT |
|
|
899
|
+
core.flags.SHABBAT_MEVARCHIM |
|
|
900
|
+
core.flags.MOLAD |
|
|
901
|
+
core.flags.USER_EVENT |
|
|
902
|
+
core.flags.HEBREW_DATE |
|
|
903
|
+
core.flags.MISHNA_YOMI |
|
|
904
|
+
core.flags.MODERN_HOLIDAY |
|
|
905
|
+
core.flags.YERUSHALMI_YOMI;
|
|
887
906
|
/**
|
|
888
907
|
* Based on the event date, type and title, finds the relevant leyning key
|
|
889
908
|
* @param ev event
|
|
@@ -907,13 +926,15 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
907
926
|
const day = hd.getDate();
|
|
908
927
|
const dow = hd.abs() % 7;
|
|
909
928
|
const month = hd.getMonth();
|
|
910
|
-
const isShabbat =
|
|
911
|
-
const isRoshChodesh =
|
|
929
|
+
const isShabbat = dow == 6;
|
|
930
|
+
const isRoshChodesh = day == 1 || day == 30;
|
|
912
931
|
const holiday = ev.basename();
|
|
913
932
|
const isPesach = holiday === 'Pesach';
|
|
914
933
|
if (il && isPesach) {
|
|
915
934
|
if (isShabbat) {
|
|
916
|
-
return day === 15 || day === 21
|
|
935
|
+
return day === 15 || day === 21
|
|
936
|
+
? desc + ' (on Shabbat)'
|
|
937
|
+
: 'Pesach Shabbat Chol ha-Moed';
|
|
917
938
|
}
|
|
918
939
|
return desc;
|
|
919
940
|
}
|
|
@@ -930,10 +951,10 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
930
951
|
return 'Sukkot Final Day (Hoshana Raba)';
|
|
931
952
|
}
|
|
932
953
|
if (isPesach && cholHaMoedDay) {
|
|
933
|
-
if (dow === 0 && desc ===
|
|
954
|
+
if (dow === 0 && desc === "Pesach IV (CH''M)") {
|
|
934
955
|
return 'Pesach Chol ha-Moed Day 2 on Sunday';
|
|
935
956
|
}
|
|
936
|
-
else if (dow === 1 && desc ===
|
|
957
|
+
else if (dow === 1 && desc === "Pesach V (CH''M)") {
|
|
937
958
|
return 'Pesach Chol ha-Moed Day 3 on Monday';
|
|
938
959
|
}
|
|
939
960
|
}
|
|
@@ -945,7 +966,7 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
945
966
|
return 'Shabbat Rosh Chodesh Chanukah';
|
|
946
967
|
}
|
|
947
968
|
else if (isRoshChodesh && chanukahDay == 7) {
|
|
948
|
-
return
|
|
969
|
+
return 'Chanukah Day 7 (on Rosh Chodesh)';
|
|
949
970
|
}
|
|
950
971
|
else if (isShabbat) {
|
|
951
972
|
return `Chanukah Day ${chanukahDay} (on Shabbat)`;
|
|
@@ -954,7 +975,8 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
954
975
|
return `Chanukah Day ${chanukahDay}`;
|
|
955
976
|
}
|
|
956
977
|
}
|
|
957
|
-
if (isRoshChodesh &&
|
|
978
|
+
if (isRoshChodesh &&
|
|
979
|
+
(desc == 'Shabbat HaChodesh' || desc == 'Shabbat Shekalim')) {
|
|
958
980
|
return desc + ' (on Rosh Chodesh)';
|
|
959
981
|
}
|
|
960
982
|
if (il && desc == 'Shmini Atzeret') {
|
|
@@ -1001,8 +1023,8 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
1001
1023
|
if (isRoshChodesh) {
|
|
1002
1024
|
return desc;
|
|
1003
1025
|
}
|
|
1004
|
-
if (desc ===
|
|
1005
|
-
return
|
|
1026
|
+
if (desc === "Tish'a B'Av (observed)") {
|
|
1027
|
+
return "Tish'a B'Av";
|
|
1006
1028
|
}
|
|
1007
1029
|
return undefined;
|
|
1008
1030
|
}
|
|
@@ -1079,7 +1101,7 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
1079
1101
|
}
|
|
1080
1102
|
const parshaName = parshaToString(parsha);
|
|
1081
1103
|
const events0 = core.HebrewCalendar.getHolidaysOnDate(hd, il) || [];
|
|
1082
|
-
const events = events0.filter(
|
|
1104
|
+
const events = events0.filter(ev => !(ev.getFlags() & core.flags.ROSH_CHODESH));
|
|
1083
1105
|
for (const ev of events) {
|
|
1084
1106
|
if (ev.getDesc() === 'Shabbat Shuva') {
|
|
1085
1107
|
handleSpecial(`Shabbat Shuva (with ${parshaName})`);
|
|
@@ -1099,9 +1121,9 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
1099
1121
|
handleSpecial('Pinchas occurring after 17 Tammuz');
|
|
1100
1122
|
}
|
|
1101
1123
|
else if (day === 30 || day === 1) {
|
|
1102
|
-
const key =
|
|
1103
|
-
`${parshaName} on Shabbat Rosh Chodesh`
|
|
1104
|
-
'Shabbat Rosh Chodesh';
|
|
1124
|
+
const key = parshaName === 'Masei' || parshaName === 'Matot-Masei'
|
|
1125
|
+
? `${parshaName} on Shabbat Rosh Chodesh`
|
|
1126
|
+
: 'Shabbat Rosh Chodesh';
|
|
1105
1127
|
handleSpecial(key);
|
|
1106
1128
|
}
|
|
1107
1129
|
else if (parshaName === 'Ki Teitzei' && day === 14) {
|
|
@@ -1113,7 +1135,8 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
1113
1135
|
// Source: Luaḥ Hashanah, Rabbi Miles B. Cohen and Leslie Rubin
|
|
1114
1136
|
handleSpecial('Ki Teitzei with 3rd Haftarah of Consolation');
|
|
1115
1137
|
}
|
|
1116
|
-
else if (parshaName === 'Kedoshim' &&
|
|
1138
|
+
else if (parshaName === 'Kedoshim' &&
|
|
1139
|
+
(day === 26 || day === 28 || day === 6)) {
|
|
1117
1140
|
// Kedoshim is read separately from Achrei Mot in ~37% of years.
|
|
1118
1141
|
// When this happens, it is will be read on
|
|
1119
1142
|
// 26th or 28th of Nisan (Achrei Mot was Shabbat HaGadol, ~10%),
|
|
@@ -1153,7 +1176,9 @@ function getLeyningForHolidayKey(key, cholHaMoedDay, il) {
|
|
|
1153
1176
|
return undefined;
|
|
1154
1177
|
}
|
|
1155
1178
|
const israelOnly = src.il;
|
|
1156
|
-
if (typeof israelOnly === 'boolean' &&
|
|
1179
|
+
if (typeof israelOnly === 'boolean' &&
|
|
1180
|
+
typeof il === 'boolean' &&
|
|
1181
|
+
il !== israelOnly) {
|
|
1157
1182
|
return undefined;
|
|
1158
1183
|
}
|
|
1159
1184
|
const leyning = {
|
|
@@ -1177,15 +1202,15 @@ function getLeyningForHolidayKey(key, cholHaMoedDay, il) {
|
|
|
1177
1202
|
leyning.summaryParts = parts;
|
|
1178
1203
|
}
|
|
1179
1204
|
}
|
|
1180
|
-
Object.values(leyning.fullkriyah).map(
|
|
1205
|
+
Object.values(leyning.fullkriyah).map(aliyah => calculateNumVerses(aliyah));
|
|
1181
1206
|
}
|
|
1182
1207
|
if (src.haft) {
|
|
1183
|
-
const haft = leyning.haft = cloneHaftara(src.haft);
|
|
1208
|
+
const haft = (leyning.haft = cloneHaftara(src.haft));
|
|
1184
1209
|
leyning.haftara = makeSummaryFromParts(haft);
|
|
1185
1210
|
leyning.haftaraNumV = sumVerses(haft);
|
|
1186
1211
|
}
|
|
1187
1212
|
if (src.seph) {
|
|
1188
|
-
const seph = leyning.seph = cloneHaftara(src.seph);
|
|
1213
|
+
const seph = (leyning.seph = cloneHaftara(src.seph));
|
|
1189
1214
|
leyning.sephardic = makeSummaryFromParts(seph);
|
|
1190
1215
|
leyning.sephardicNumV = sumVerses(seph);
|
|
1191
1216
|
}
|
|
@@ -2541,7 +2566,7 @@ function makeLeyningNames(parsha) {
|
|
|
2541
2566
|
const name = parshaToString(parsha);
|
|
2542
2567
|
return {
|
|
2543
2568
|
en: name,
|
|
2544
|
-
he: parsha.map(
|
|
2569
|
+
he: parsha.map(s => core.Locale.lookupTranslation(s, 'he')).join('־'),
|
|
2545
2570
|
};
|
|
2546
2571
|
}
|
|
2547
2572
|
/**
|
|
@@ -2578,13 +2603,13 @@ function getLeyningForParshaShabbatOnly(parsha) {
|
|
|
2578
2603
|
const hkey = getHaftaraKey(parshaNameArray);
|
|
2579
2604
|
const haft0 = parshiyotObj[hkey].haft;
|
|
2580
2605
|
if (haft0) {
|
|
2581
|
-
const haft = result.haft = cloneHaftara(haft0);
|
|
2606
|
+
const haft = (result.haft = cloneHaftara(haft0));
|
|
2582
2607
|
result.haftara = makeSummaryFromParts(haft);
|
|
2583
2608
|
result.haftaraNumV = sumVerses(haft);
|
|
2584
2609
|
}
|
|
2585
2610
|
const seph0 = parshiyotObj[hkey].seph;
|
|
2586
2611
|
if (seph0) {
|
|
2587
|
-
const seph = result.seph = cloneHaftara(seph0);
|
|
2612
|
+
const seph = (result.seph = cloneHaftara(seph0));
|
|
2588
2613
|
result.sephardic = makeSummaryFromParts(seph);
|
|
2589
2614
|
result.sephardicNumV = sumVerses(seph);
|
|
2590
2615
|
}
|
|
@@ -2643,11 +2668,11 @@ function getLeyningForParshaHaShavua(ev, il = false) {
|
|
|
2643
2668
|
const special = specialReadings2(parsha, hd, il, result.fullkriyah);
|
|
2644
2669
|
const reason = special.reason;
|
|
2645
2670
|
if (special.haft) {
|
|
2646
|
-
const haft = result.haft = cloneHaftara(special.haft);
|
|
2671
|
+
const haft = (result.haft = cloneHaftara(special.haft));
|
|
2647
2672
|
result.haftara = makeSummaryFromParts(haft);
|
|
2648
2673
|
result.haftaraNumV = sumVerses(haft);
|
|
2649
2674
|
if (special.seph) {
|
|
2650
|
-
const seph = result.seph = cloneHaftara(special.seph);
|
|
2675
|
+
const seph = (result.seph = cloneHaftara(special.seph));
|
|
2651
2676
|
result.sephardic = makeSummaryFromParts(seph);
|
|
2652
2677
|
result.sephardicNumV = sumVerses(seph);
|
|
2653
2678
|
}
|
|
@@ -2788,6 +2813,9 @@ function getLeyningOnDate(hdate, il, wantarray = false) {
|
|
|
2788
2813
|
}
|
|
2789
2814
|
const reading = getLeyningForHoliday(ev, il);
|
|
2790
2815
|
if (reading) {
|
|
2816
|
+
// Skip duplicate readings from overlapping events (eg, Rosh Chodesh + Chanukah)
|
|
2817
|
+
if (arr.some(r => r.name.en === reading.name.en))
|
|
2818
|
+
continue;
|
|
2791
2819
|
const fk = reading.fullkriyah;
|
|
2792
2820
|
if (fk) {
|
|
2793
2821
|
hasFullKriyah = true;
|
|
@@ -2843,14 +2871,16 @@ function getMincha(ev, il) {
|
|
|
2843
2871
|
}
|
|
2844
2872
|
|
|
2845
2873
|
const fmt = new Intl.DateTimeFormat('en-US', {
|
|
2846
|
-
year: 'numeric',
|
|
2874
|
+
year: 'numeric',
|
|
2875
|
+
month: 'short',
|
|
2876
|
+
day: '2-digit',
|
|
2847
2877
|
});
|
|
2848
2878
|
function fmtDate(dt) {
|
|
2849
2879
|
const s = fmt.format(dt).split(' ');
|
|
2850
2880
|
return s[1].substring(0, 2) + '-' + s[0] + '-' + s[2];
|
|
2851
2881
|
}
|
|
2852
2882
|
function getParshaDates(events) {
|
|
2853
|
-
const parshaEvents = events.filter(
|
|
2883
|
+
const parshaEvents = events.filter(ev => ev.getFlags() === core.flags.PARSHA_HASHAVUA);
|
|
2854
2884
|
const emptyMap = {};
|
|
2855
2885
|
const parshaDates = parshaEvents.reduce((set, ev) => {
|
|
2856
2886
|
set[ev.getDate().toString()] = true;
|
|
@@ -2869,7 +2899,8 @@ function writeFullKriyahCsv(stream, hyear, il) {
|
|
|
2869
2899
|
const parshaDates = getParshaDates(events);
|
|
2870
2900
|
stream.write('"Date","Parashah","Aliyah","Reading","Verses"\r\n');
|
|
2871
2901
|
for (const ev of events) {
|
|
2872
|
-
if (ev.getFlags() === core.flags.PARSHA_HASHAVUA ||
|
|
2902
|
+
if (ev.getFlags() === core.flags.PARSHA_HASHAVUA ||
|
|
2903
|
+
!parshaDates[ev.getDate().toString()]) {
|
|
2873
2904
|
writeFullKriyahEvent(stream, ev, il);
|
|
2874
2905
|
}
|
|
2875
2906
|
}
|
|
@@ -2890,7 +2921,9 @@ function writeFullKriyahEvent(stream, ev, il) {
|
|
|
2890
2921
|
}
|
|
2891
2922
|
const mask = ev.getFlags();
|
|
2892
2923
|
const isParsha = mask === core.flags.PARSHA_HASHAVUA;
|
|
2893
|
-
const reading = isParsha
|
|
2924
|
+
const reading = isParsha
|
|
2925
|
+
? getLeyningForParshaHaShavua(ev, il)
|
|
2926
|
+
: getLeyningForHoliday(ev, il);
|
|
2894
2927
|
if (reading) {
|
|
2895
2928
|
writeCsvLines(stream, ev, reading, il, isParsha);
|
|
2896
2929
|
if (!isParsha) {
|
|
@@ -2919,7 +2952,9 @@ function writeHolidayMincha(stream, ev, il) {
|
|
|
2919
2952
|
* Formats reading for CSV
|
|
2920
2953
|
*/
|
|
2921
2954
|
function writeCsvLines(stream, ev, reading, il, isParsha) {
|
|
2922
|
-
const parsha = isParsha
|
|
2955
|
+
const parsha = isParsha
|
|
2956
|
+
? ev.basename()
|
|
2957
|
+
: getLeyningKeyForEvent(ev, il) || ev.render();
|
|
2923
2958
|
const date = fmtDate(ev.getDate().greg());
|
|
2924
2959
|
const lines = getFullKriyahLines(reading);
|
|
2925
2960
|
for (const s of lines) {
|
|
@@ -2959,7 +2994,11 @@ function getFullKriyahLines(reading) {
|
|
|
2959
2994
|
if ((_c = reading.reason) === null || _c === void 0 ? void 0 : _c.sephardic) {
|
|
2960
2995
|
sephardic += ' | ' + reading.reason.sephardic;
|
|
2961
2996
|
}
|
|
2962
|
-
lines.push([
|
|
2997
|
+
lines.push([
|
|
2998
|
+
'Haftara for Sephardim',
|
|
2999
|
+
sephardic,
|
|
3000
|
+
reading.sephardicNumV || '',
|
|
3001
|
+
]);
|
|
2963
3002
|
}
|
|
2964
3003
|
if (reading.triHaftara) {
|
|
2965
3004
|
const haftara = reading.triHaftara.replace(/,/g, ';');
|