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