@hebcal/leyning 8.2.6 → 8.2.8
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 +102 -74
- package/dist/bundle.min.js +2 -2
- package/dist/common.d.ts +9 -1
- package/dist/getLeyningOnDate.d.ts +2 -1
- package/dist/index.cjs +102 -74
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +102 -75
- package/dist/module.d.ts +12 -3
- package/package.json +12 -12
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/leyning v8.2.
|
|
1
|
+
/*! @hebcal/leyning v8.2.8 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var core = require('@hebcal/core');
|
|
@@ -55,7 +55,19 @@ var numverses = {
|
|
|
55
55
|
* Names of the books of the Torah. BOOK[1] === 'Genesis'
|
|
56
56
|
* @readonly
|
|
57
57
|
*/
|
|
58
|
-
const BOOK = [
|
|
58
|
+
const BOOK = [
|
|
59
|
+
'',
|
|
60
|
+
'Genesis',
|
|
61
|
+
'Exodus',
|
|
62
|
+
'Leviticus',
|
|
63
|
+
'Numbers',
|
|
64
|
+
'Deuteronomy',
|
|
65
|
+
];
|
|
66
|
+
/**
|
|
67
|
+
* The number of verses in each book of the Tanakh.
|
|
68
|
+
* @readonly
|
|
69
|
+
*/
|
|
70
|
+
const NUM_VERSES = numverses;
|
|
59
71
|
/**
|
|
60
72
|
* Formats parsha as a string
|
|
61
73
|
* @param parsha untranslated name like 'Pinchas' or ['Pinchas'] or ['Matot','Masei']
|
|
@@ -64,11 +76,13 @@ function parshaToString(parsha) {
|
|
|
64
76
|
if (typeof parsha === 'string') {
|
|
65
77
|
return parsha;
|
|
66
78
|
}
|
|
67
|
-
else if (!Array.isArray(parsha) ||
|
|
79
|
+
else if (!Array.isArray(parsha) ||
|
|
80
|
+
parsha.length === 0 ||
|
|
81
|
+
parsha.length > 2) {
|
|
68
82
|
throw new TypeError(`Bad parsha argument: ${parsha}`);
|
|
69
83
|
}
|
|
70
84
|
let s = parsha[0];
|
|
71
|
-
if (parsha.length
|
|
85
|
+
if (parsha.length === 2) {
|
|
72
86
|
s += '-' + parsha[1];
|
|
73
87
|
}
|
|
74
88
|
return s;
|
|
@@ -92,7 +106,7 @@ function calculateNumVerses(aliyah) {
|
|
|
92
106
|
aliyah.v = v2 - v1 + 1;
|
|
93
107
|
}
|
|
94
108
|
else if (typeof aliyah.k === 'string') {
|
|
95
|
-
const numv =
|
|
109
|
+
const numv = NUM_VERSES[aliyah.k];
|
|
96
110
|
if (typeof numv !== 'object' || !numv.length) {
|
|
97
111
|
throw new ReferenceError(`Can't find numverses for ${aliyah.k}`);
|
|
98
112
|
}
|
|
@@ -131,16 +145,16 @@ function formatAliyahShort(aliyah, showBook) {
|
|
|
131
145
|
* @private
|
|
132
146
|
*/
|
|
133
147
|
function isChapVerseBefore(a, b) {
|
|
134
|
-
const cv1 = a.split(':').map(
|
|
135
|
-
const cv2 = b.split(':').map(
|
|
136
|
-
return
|
|
148
|
+
const cv1 = a.split(':').map(x => +x);
|
|
149
|
+
const cv2 = b.split(':').map(x => +x);
|
|
150
|
+
return cv1[0] * 100 + cv1[1] < cv2[0] * 100 + cv2[1];
|
|
137
151
|
}
|
|
138
152
|
/**
|
|
139
153
|
* Summarizes an `AliyotMap` by collapsing all adjacent aliyot.
|
|
140
154
|
* Finds any non-overlapping parts (e.g. special 7th aliyah or maftir)
|
|
141
155
|
*/
|
|
142
156
|
function makeLeyningParts(aliyot) {
|
|
143
|
-
const nums = Object.keys(aliyot).filter(
|
|
157
|
+
const nums = Object.keys(aliyot).filter(x => {
|
|
144
158
|
if (x.length === 1) {
|
|
145
159
|
return true;
|
|
146
160
|
}
|
|
@@ -153,15 +167,17 @@ function makeLeyningParts(aliyot) {
|
|
|
153
167
|
for (let i = 0; i < nums.length; i++) {
|
|
154
168
|
const num = nums[i];
|
|
155
169
|
const aliyah = aliyot[num];
|
|
156
|
-
if (
|
|
170
|
+
if (i === nums.length - 1 && aliyah.k === end.k && aliyah.e === end.e) {
|
|
157
171
|
// short-circuit when final aliyah is within the previous (e.g. M inside of 7)
|
|
158
172
|
continue;
|
|
159
173
|
}
|
|
160
|
-
const prevEndChap = +
|
|
161
|
-
const curStartChap = +
|
|
174
|
+
const prevEndChap = +end.e.split(':')[0];
|
|
175
|
+
const curStartChap = +aliyah.b.split(':')[0];
|
|
162
176
|
const sameOrNextChap = curStartChap === prevEndChap || curStartChap === prevEndChap + 1;
|
|
163
|
-
if (
|
|
164
|
-
(aliyah.k !== start.k ||
|
|
177
|
+
if (i !== 0 &&
|
|
178
|
+
(aliyah.k !== start.k ||
|
|
179
|
+
isChapVerseBefore(aliyah.b, start.e) ||
|
|
180
|
+
!sameOrNextChap)) {
|
|
165
181
|
parts.push({ k: start.k, b: start.b, e: end.e });
|
|
166
182
|
start = aliyah;
|
|
167
183
|
}
|
|
@@ -227,7 +243,9 @@ function cloneHaftara(haft) {
|
|
|
227
243
|
* Returns the total number of verses in an array of Aliyah (or haftarah) objects
|
|
228
244
|
*/
|
|
229
245
|
function sumVerses(aliyot) {
|
|
230
|
-
return Array.isArray(aliyot)
|
|
246
|
+
return Array.isArray(aliyot)
|
|
247
|
+
? aliyot.reduce((prev, cur) => prev + cur.v, 0)
|
|
248
|
+
: aliyot.v;
|
|
231
249
|
}
|
|
232
250
|
|
|
233
251
|
var festivals0 = { "Pesach I": {
|
|
@@ -882,9 +900,15 @@ function lookupFestival(holiday) {
|
|
|
882
900
|
return result;
|
|
883
901
|
}
|
|
884
902
|
|
|
885
|
-
const HOLIDAY_IGNORE_MASK = core.flags.DAF_YOMI |
|
|
886
|
-
core.flags.
|
|
887
|
-
core.flags.
|
|
903
|
+
const HOLIDAY_IGNORE_MASK = core.flags.DAF_YOMI |
|
|
904
|
+
core.flags.OMER_COUNT |
|
|
905
|
+
core.flags.SHABBAT_MEVARCHIM |
|
|
906
|
+
core.flags.MOLAD |
|
|
907
|
+
core.flags.USER_EVENT |
|
|
908
|
+
core.flags.HEBREW_DATE |
|
|
909
|
+
core.flags.MISHNA_YOMI |
|
|
910
|
+
core.flags.MODERN_HOLIDAY |
|
|
911
|
+
core.flags.YERUSHALMI_YOMI;
|
|
888
912
|
/**
|
|
889
913
|
* Based on the event date, type and title, finds the relevant leyning key
|
|
890
914
|
* @param ev event
|
|
@@ -908,17 +932,19 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
908
932
|
const day = hd.getDate();
|
|
909
933
|
const dow = hd.abs() % 7;
|
|
910
934
|
const month = hd.getMonth();
|
|
911
|
-
const isShabbat =
|
|
912
|
-
const isRoshChodesh =
|
|
935
|
+
const isShabbat = dow === 6;
|
|
936
|
+
const isRoshChodesh = day === 1 || day === 30;
|
|
913
937
|
const holiday = ev.basename();
|
|
914
938
|
const isPesach = holiday === 'Pesach';
|
|
915
939
|
if (il && isPesach) {
|
|
916
940
|
if (isShabbat) {
|
|
917
|
-
return day === 15 || day === 21
|
|
941
|
+
return day === 15 || day === 21
|
|
942
|
+
? desc + ' (on Shabbat)'
|
|
943
|
+
: 'Pesach Shabbat Chol ha-Moed';
|
|
918
944
|
}
|
|
919
945
|
return desc;
|
|
920
946
|
}
|
|
921
|
-
if (day
|
|
947
|
+
if (day === 1 && month === core.months.TISHREI) {
|
|
922
948
|
return isShabbat ? 'Rosh Hashana I (on Shabbat)' : 'Rosh Hashana I';
|
|
923
949
|
}
|
|
924
950
|
const cholHaMoedDay = ev.cholHaMoedDay;
|
|
@@ -927,14 +953,14 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
927
953
|
if (isShabbat) {
|
|
928
954
|
return holiday + ' Shabbat Chol ha-Moed';
|
|
929
955
|
}
|
|
930
|
-
else if (desc
|
|
956
|
+
else if (desc === 'Sukkot VII (Hoshana Raba)') {
|
|
931
957
|
return 'Sukkot Final Day (Hoshana Raba)';
|
|
932
958
|
}
|
|
933
959
|
if (isPesach && cholHaMoedDay) {
|
|
934
|
-
if (dow === 0 && desc ===
|
|
960
|
+
if (dow === 0 && desc === "Pesach IV (CH''M)") {
|
|
935
961
|
return 'Pesach Chol ha-Moed Day 2 on Sunday';
|
|
936
962
|
}
|
|
937
|
-
else if (dow === 1 && desc ===
|
|
963
|
+
else if (dow === 1 && desc === "Pesach V (CH''M)") {
|
|
938
964
|
return 'Pesach Chol ha-Moed Day 3 on Monday';
|
|
939
965
|
}
|
|
940
966
|
}
|
|
@@ -945,8 +971,8 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
945
971
|
if (isShabbat && isRoshChodesh) {
|
|
946
972
|
return 'Shabbat Rosh Chodesh Chanukah';
|
|
947
973
|
}
|
|
948
|
-
else if (isRoshChodesh && chanukahDay
|
|
949
|
-
return
|
|
974
|
+
else if (isRoshChodesh && chanukahDay === 7) {
|
|
975
|
+
return 'Chanukah Day 7 (on Rosh Chodesh)';
|
|
950
976
|
}
|
|
951
977
|
else if (isShabbat) {
|
|
952
978
|
return `Chanukah Day ${chanukahDay} (on Shabbat)`;
|
|
@@ -955,16 +981,17 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
955
981
|
return `Chanukah Day ${chanukahDay}`;
|
|
956
982
|
}
|
|
957
983
|
}
|
|
958
|
-
if (isRoshChodesh &&
|
|
984
|
+
if (isRoshChodesh &&
|
|
985
|
+
(desc === 'Shabbat HaChodesh' || desc === 'Shabbat Shekalim')) {
|
|
959
986
|
return desc + ' (on Rosh Chodesh)';
|
|
960
987
|
}
|
|
961
|
-
if (il && desc
|
|
988
|
+
if (il && desc === 'Shmini Atzeret') {
|
|
962
989
|
return 'Simchat Torah';
|
|
963
990
|
}
|
|
964
991
|
if (desc === 'Chag HaBanot') {
|
|
965
992
|
return undefined;
|
|
966
993
|
}
|
|
967
|
-
if (isShabbat && 'Shabbat'
|
|
994
|
+
if (isShabbat && 'Shabbat' !== desc.substring(0, 7)) {
|
|
968
995
|
if (isRoshChodesh) {
|
|
969
996
|
if (desc === 'Rosh Chodesh Tevet') {
|
|
970
997
|
return 'Shabbat Rosh Chodesh Chanukah';
|
|
@@ -1002,8 +1029,8 @@ function getLeyningKeyForEvent(ev, il = false) {
|
|
|
1002
1029
|
if (isRoshChodesh) {
|
|
1003
1030
|
return desc;
|
|
1004
1031
|
}
|
|
1005
|
-
if (desc ===
|
|
1006
|
-
return
|
|
1032
|
+
if (desc === "Tish'a B'Av (observed)") {
|
|
1033
|
+
return "Tish'a B'Av";
|
|
1007
1034
|
}
|
|
1008
1035
|
return undefined;
|
|
1009
1036
|
}
|
|
@@ -1080,7 +1107,7 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
1080
1107
|
}
|
|
1081
1108
|
const parshaName = parshaToString(parsha);
|
|
1082
1109
|
const events0 = core.HebrewCalendar.getHolidaysOnDate(hd, il) || [];
|
|
1083
|
-
const events = events0.filter(
|
|
1110
|
+
const events = events0.filter(ev => !(ev.getFlags() & core.flags.ROSH_CHODESH));
|
|
1084
1111
|
for (const ev of events) {
|
|
1085
1112
|
if (ev.getDesc() === 'Shabbat Shuva') {
|
|
1086
1113
|
handleSpecial(`Shabbat Shuva (with ${parshaName})`);
|
|
@@ -1100,9 +1127,9 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
1100
1127
|
handleSpecial('Pinchas occurring after 17 Tammuz');
|
|
1101
1128
|
}
|
|
1102
1129
|
else if (day === 30 || day === 1) {
|
|
1103
|
-
const key =
|
|
1104
|
-
`${parshaName} on Shabbat Rosh Chodesh`
|
|
1105
|
-
'Shabbat Rosh Chodesh';
|
|
1130
|
+
const key = parshaName === 'Masei' || parshaName === 'Matot-Masei'
|
|
1131
|
+
? `${parshaName} on Shabbat Rosh Chodesh`
|
|
1132
|
+
: 'Shabbat Rosh Chodesh';
|
|
1106
1133
|
handleSpecial(key);
|
|
1107
1134
|
}
|
|
1108
1135
|
else if (parshaName === 'Ki Teitzei' && day === 14) {
|
|
@@ -1114,7 +1141,8 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
1114
1141
|
// Source: Luaḥ Hashanah, Rabbi Miles B. Cohen and Leslie Rubin
|
|
1115
1142
|
handleSpecial('Ki Teitzei with 3rd Haftarah of Consolation');
|
|
1116
1143
|
}
|
|
1117
|
-
else if (parshaName === 'Kedoshim' &&
|
|
1144
|
+
else if (parshaName === 'Kedoshim' &&
|
|
1145
|
+
(day === 26 || day === 28 || day === 6)) {
|
|
1118
1146
|
// Kedoshim is read separately from Achrei Mot in ~37% of years.
|
|
1119
1147
|
// When this happens, it is will be read on
|
|
1120
1148
|
// 26th or 28th of Nisan (Achrei Mot was Shabbat HaGadol, ~10%),
|
|
@@ -1154,7 +1182,9 @@ function getLeyningForHolidayKey(key, cholHaMoedDay, il) {
|
|
|
1154
1182
|
return undefined;
|
|
1155
1183
|
}
|
|
1156
1184
|
const israelOnly = src.il;
|
|
1157
|
-
if (typeof israelOnly === 'boolean' &&
|
|
1185
|
+
if (typeof israelOnly === 'boolean' &&
|
|
1186
|
+
typeof il === 'boolean' &&
|
|
1187
|
+
il !== israelOnly) {
|
|
1158
1188
|
return undefined;
|
|
1159
1189
|
}
|
|
1160
1190
|
const leyning = {
|
|
@@ -1178,21 +1208,21 @@ function getLeyningForHolidayKey(key, cholHaMoedDay, il) {
|
|
|
1178
1208
|
leyning.summaryParts = parts;
|
|
1179
1209
|
}
|
|
1180
1210
|
}
|
|
1181
|
-
Object.values(leyning.fullkriyah).map(
|
|
1211
|
+
Object.values(leyning.fullkriyah).map(aliyah => calculateNumVerses(aliyah));
|
|
1182
1212
|
}
|
|
1183
1213
|
if (src.haft) {
|
|
1184
|
-
const haft = leyning.haft = cloneHaftara(src.haft);
|
|
1214
|
+
const haft = (leyning.haft = cloneHaftara(src.haft));
|
|
1185
1215
|
leyning.haftara = makeSummaryFromParts(haft);
|
|
1186
1216
|
leyning.haftaraNumV = sumVerses(haft);
|
|
1187
1217
|
}
|
|
1188
1218
|
if (src.seph) {
|
|
1189
|
-
const seph = leyning.seph = cloneHaftara(src.seph);
|
|
1219
|
+
const seph = (leyning.seph = cloneHaftara(src.seph));
|
|
1190
1220
|
leyning.sephardic = makeSummaryFromParts(seph);
|
|
1191
1221
|
leyning.sephardicNumV = sumVerses(seph);
|
|
1192
1222
|
}
|
|
1193
1223
|
if (src.megillah) {
|
|
1194
1224
|
const book = src.megillah;
|
|
1195
|
-
const chaps =
|
|
1225
|
+
const chaps = NUM_VERSES[book];
|
|
1196
1226
|
const m = {};
|
|
1197
1227
|
for (let i = 1; i < chaps.length; i++) {
|
|
1198
1228
|
const numv = chaps[i];
|
|
@@ -2524,10 +2554,10 @@ const parshiyotObj = parshiyotObj0;
|
|
|
2524
2554
|
*/
|
|
2525
2555
|
function getHaftaraKey(parsha) {
|
|
2526
2556
|
const first = parsha[0];
|
|
2527
|
-
if (parsha.length === 2 && first
|
|
2557
|
+
if (parsha.length === 2 && first === 'Achrei Mot') {
|
|
2528
2558
|
return parshaToString(parsha); // 'Achrei Mot-Kedoshim'
|
|
2529
2559
|
}
|
|
2530
|
-
if (parsha.length === 1 || first
|
|
2560
|
+
if (parsha.length === 1 || first === 'Nitzavim') {
|
|
2531
2561
|
return first;
|
|
2532
2562
|
}
|
|
2533
2563
|
else {
|
|
@@ -2542,7 +2572,7 @@ function makeLeyningNames(parsha) {
|
|
|
2542
2572
|
const name = parshaToString(parsha);
|
|
2543
2573
|
return {
|
|
2544
2574
|
en: name,
|
|
2545
|
-
he: parsha.map(
|
|
2575
|
+
he: parsha.map(s => core.Locale.lookupTranslation(s, 'he')).join('־'),
|
|
2546
2576
|
};
|
|
2547
2577
|
}
|
|
2548
2578
|
/**
|
|
@@ -2579,13 +2609,13 @@ function getLeyningForParshaShabbatOnly(parsha) {
|
|
|
2579
2609
|
const hkey = getHaftaraKey(parshaNameArray);
|
|
2580
2610
|
const haft0 = parshiyotObj[hkey].haft;
|
|
2581
2611
|
if (haft0) {
|
|
2582
|
-
const haft = result.haft = cloneHaftara(haft0);
|
|
2612
|
+
const haft = (result.haft = cloneHaftara(haft0));
|
|
2583
2613
|
result.haftara = makeSummaryFromParts(haft);
|
|
2584
2614
|
result.haftaraNumV = sumVerses(haft);
|
|
2585
2615
|
}
|
|
2586
2616
|
const seph0 = parshiyotObj[hkey].seph;
|
|
2587
2617
|
if (seph0) {
|
|
2588
|
-
const seph = result.seph = cloneHaftara(seph0);
|
|
2618
|
+
const seph = (result.seph = cloneHaftara(seph0));
|
|
2589
2619
|
result.sephardic = makeSummaryFromParts(seph);
|
|
2590
2620
|
result.sephardicNumV = sumVerses(seph);
|
|
2591
2621
|
}
|
|
@@ -2633,7 +2663,7 @@ function getLeyningForParshaHaShavua(ev, il = false) {
|
|
|
2633
2663
|
if (typeof ev !== 'object' || typeof ev.getFlags !== 'function') {
|
|
2634
2664
|
throw new TypeError(`Bad event argument: ${ev}`);
|
|
2635
2665
|
}
|
|
2636
|
-
else if (ev.getFlags()
|
|
2666
|
+
else if (ev.getFlags() !== core.flags.PARSHA_HASHAVUA) {
|
|
2637
2667
|
throw new TypeError(`Event must be parsha hashavua: ${ev.getDesc()}`);
|
|
2638
2668
|
}
|
|
2639
2669
|
// first, collect the default aliyot and haftara
|
|
@@ -2644,11 +2674,11 @@ function getLeyningForParshaHaShavua(ev, il = false) {
|
|
|
2644
2674
|
const special = specialReadings2(parsha, hd, il, result.fullkriyah);
|
|
2645
2675
|
const reason = special.reason;
|
|
2646
2676
|
if (special.haft) {
|
|
2647
|
-
const haft = result.haft = cloneHaftara(special.haft);
|
|
2677
|
+
const haft = (result.haft = cloneHaftara(special.haft));
|
|
2648
2678
|
result.haftara = makeSummaryFromParts(haft);
|
|
2649
2679
|
result.haftaraNumV = sumVerses(haft);
|
|
2650
2680
|
if (special.seph) {
|
|
2651
|
-
const seph = result.seph = cloneHaftara(special.seph);
|
|
2681
|
+
const seph = (result.seph = cloneHaftara(special.seph));
|
|
2652
2682
|
result.sephardic = makeSummaryFromParts(seph);
|
|
2653
2683
|
result.sephardicNumV = sumVerses(seph);
|
|
2654
2684
|
}
|
|
@@ -2743,23 +2773,6 @@ function findParshaHaShavua(saturday, il) {
|
|
|
2743
2773
|
/* NOTREACHED */
|
|
2744
2774
|
throw new Error(`can't findParshaHaShavua for ${saturday}/${il}`);
|
|
2745
2775
|
}
|
|
2746
|
-
/**
|
|
2747
|
-
* Looks up leyning for a regular Shabbat, Monday/Thursday weekday or holiday.
|
|
2748
|
-
*
|
|
2749
|
-
* If `hdate` coincides with a holiday that has Torah reading, returns the
|
|
2750
|
-
* reading for that day (see {@link getLeyningForHoliday})
|
|
2751
|
-
*
|
|
2752
|
-
* Otherwise, if `hdate` is a Saturday, returns {@link getLeyningForParshaHaShavua}
|
|
2753
|
-
*
|
|
2754
|
-
* Otherwise, if `hdate` is a Monday or Thursday, returns {@link Leyning} for the
|
|
2755
|
-
* Parashat haShavua, containing only the `weekday` aliyot (no `fullkriyah`).
|
|
2756
|
-
*
|
|
2757
|
-
* Otherwise, returns `undefined`.
|
|
2758
|
-
*
|
|
2759
|
-
* @param {HDate} hdate Hebrew Date
|
|
2760
|
-
* @param {boolean} il in Israel
|
|
2761
|
-
* @param {boolean} [wantarray] to return an array of 0 or more readings
|
|
2762
|
-
*/
|
|
2763
2776
|
function getLeyningOnDate(hdate, il, wantarray = false) {
|
|
2764
2777
|
const dow = hdate.getDay();
|
|
2765
2778
|
const arr = [];
|
|
@@ -2789,6 +2802,9 @@ function getLeyningOnDate(hdate, il, wantarray = false) {
|
|
|
2789
2802
|
}
|
|
2790
2803
|
const reading = getLeyningForHoliday(ev, il);
|
|
2791
2804
|
if (reading) {
|
|
2805
|
+
// Skip duplicate readings from overlapping events (eg, Rosh Chodesh + Chanukah)
|
|
2806
|
+
if (arr.some(r => r.name.en === reading.name.en))
|
|
2807
|
+
continue;
|
|
2792
2808
|
const fk = reading.fullkriyah;
|
|
2793
2809
|
if (fk) {
|
|
2794
2810
|
hasFullKriyah = true;
|
|
@@ -2844,14 +2860,16 @@ function getMincha(ev, il) {
|
|
|
2844
2860
|
}
|
|
2845
2861
|
|
|
2846
2862
|
const fmt = new Intl.DateTimeFormat('en-US', {
|
|
2847
|
-
year: 'numeric',
|
|
2863
|
+
year: 'numeric',
|
|
2864
|
+
month: 'short',
|
|
2865
|
+
day: '2-digit',
|
|
2848
2866
|
});
|
|
2849
2867
|
function fmtDate(dt) {
|
|
2850
2868
|
const s = fmt.format(dt).split(' ');
|
|
2851
2869
|
return s[1].substring(0, 2) + '-' + s[0] + '-' + s[2];
|
|
2852
2870
|
}
|
|
2853
2871
|
function getParshaDates(events) {
|
|
2854
|
-
const parshaEvents = events.filter(
|
|
2872
|
+
const parshaEvents = events.filter(ev => ev.getFlags() === core.flags.PARSHA_HASHAVUA);
|
|
2855
2873
|
const emptyMap = {};
|
|
2856
2874
|
const parshaDates = parshaEvents.reduce((set, ev) => {
|
|
2857
2875
|
set[ev.getDate().toString()] = true;
|
|
@@ -2870,7 +2888,8 @@ function writeFullKriyahCsv(stream, hyear, il) {
|
|
|
2870
2888
|
const parshaDates = getParshaDates(events);
|
|
2871
2889
|
stream.write('"Date","Parashah","Aliyah","Reading","Verses"\r\n');
|
|
2872
2890
|
for (const ev of events) {
|
|
2873
|
-
if (ev.getFlags() === core.flags.PARSHA_HASHAVUA ||
|
|
2891
|
+
if (ev.getFlags() === core.flags.PARSHA_HASHAVUA ||
|
|
2892
|
+
!parshaDates[ev.getDate().toString()]) {
|
|
2874
2893
|
writeFullKriyahEvent(stream, ev, il);
|
|
2875
2894
|
}
|
|
2876
2895
|
}
|
|
@@ -2891,7 +2910,9 @@ function writeFullKriyahEvent(stream, ev, il) {
|
|
|
2891
2910
|
}
|
|
2892
2911
|
const mask = ev.getFlags();
|
|
2893
2912
|
const isParsha = mask === core.flags.PARSHA_HASHAVUA;
|
|
2894
|
-
const reading = isParsha
|
|
2913
|
+
const reading = isParsha
|
|
2914
|
+
? getLeyningForParshaHaShavua(ev, il)
|
|
2915
|
+
: getLeyningForHoliday(ev, il);
|
|
2895
2916
|
if (reading) {
|
|
2896
2917
|
writeCsvLines(stream, ev, reading, il, isParsha);
|
|
2897
2918
|
if (!isParsha) {
|
|
@@ -2920,7 +2941,9 @@ function writeHolidayMincha(stream, ev, il) {
|
|
|
2920
2941
|
* Formats reading for CSV
|
|
2921
2942
|
*/
|
|
2922
2943
|
function writeCsvLines(stream, ev, reading, il, isParsha) {
|
|
2923
|
-
const parsha = isParsha
|
|
2944
|
+
const parsha = isParsha
|
|
2945
|
+
? ev.basename()
|
|
2946
|
+
: getLeyningKeyForEvent(ev, il) || ev.render();
|
|
2924
2947
|
const date = fmtDate(ev.getDate().greg());
|
|
2925
2948
|
const lines = getFullKriyahLines(reading);
|
|
2926
2949
|
for (const s of lines) {
|
|
@@ -2938,7 +2961,7 @@ function getFullKriyahLines(reading) {
|
|
|
2938
2961
|
if (reading.fullkriyah) {
|
|
2939
2962
|
for (const [num, a] of Object.entries(reading.fullkriyah)) {
|
|
2940
2963
|
if (typeof a !== 'undefined') {
|
|
2941
|
-
const k = num
|
|
2964
|
+
const k = num === 'M' ? 'maf' : num;
|
|
2942
2965
|
let aliyah = formatAliyahWithBook(a);
|
|
2943
2966
|
if ((_a = reading.reason) === null || _a === void 0 ? void 0 : _a[num]) {
|
|
2944
2967
|
aliyah += ' | ' + reading.reason[num];
|
|
@@ -2960,7 +2983,11 @@ function getFullKriyahLines(reading) {
|
|
|
2960
2983
|
if ((_c = reading.reason) === null || _c === void 0 ? void 0 : _c.sephardic) {
|
|
2961
2984
|
sephardic += ' | ' + reading.reason.sephardic;
|
|
2962
2985
|
}
|
|
2963
|
-
lines.push([
|
|
2986
|
+
lines.push([
|
|
2987
|
+
'Haftara for Sephardim',
|
|
2988
|
+
sephardic,
|
|
2989
|
+
reading.sephardicNumV || '',
|
|
2990
|
+
]);
|
|
2964
2991
|
}
|
|
2965
2992
|
if (reading.triHaftara) {
|
|
2966
2993
|
const haftara = reading.triHaftara.replace(/,/g, ';');
|
|
@@ -2978,6 +3005,7 @@ function getFullKriyahLines(reading) {
|
|
|
2978
3005
|
}
|
|
2979
3006
|
|
|
2980
3007
|
exports.BOOK = BOOK;
|
|
3008
|
+
exports.NUM_VERSES = NUM_VERSES;
|
|
2981
3009
|
exports.calculateNumVerses = calculateNumVerses;
|
|
2982
3010
|
exports.clone = clone;
|
|
2983
3011
|
exports.cloneHaftara = cloneHaftara;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,5 @@ export * from './specialReadings';
|
|
|
7
7
|
export * from './getLeyningForHoliday';
|
|
8
8
|
export * from './leyning';
|
|
9
9
|
export { getLeyningOnDate } from './getLeyningOnDate';
|
|
10
|
-
export { writeFullKriyahCsv, writeCsvLines, writeHolidayMincha, StringToBoolMap, getParshaDates } from './csv';
|
|
10
|
+
export { writeFullKriyahCsv, writeCsvLines, writeHolidayMincha, StringToBoolMap, getParshaDates, } from './csv';
|
|
11
11
|
export * from './clone';
|