@hebcal/leyning 9.0.5 → 9.1.0

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 CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/leyning v9.0.5 */
1
+ /*! @hebcal/leyning v9.1.0 */
2
2
  var hebcal__leyning = (function (exports, locale, event, holidays, sedra, ParshaEvent) {
3
3
  'use strict';
4
4
 
@@ -17,7 +17,7 @@ const poHeNoNikud$1 = {
17
17
  };
18
18
  locale.Locale.addTranslations('he-x-NoNikud', poHeNoNikud$1);
19
19
 
20
- const Genesis=[0,31,25,24,26,32,22,24,22,29,32,32,20,18,24,21,16,27,33,38,18,34,24,20,67,34,35,46,22,35,43,54,33,20,31,29,43,36,30,23,23,57,38,34,34,28,34,31,22,33,26];const Exodus=[0,22,25,22,31,23,30,29,28,35,29,10,51,22,31,27,36,16,27,25,26,37,30,33,18,40,37,21,43,46,38,18,35,23,35,35,38,29,31,43,38];const Leviticus=[0,17,16,17,35,26,23,38,36,24,20,47,8,59,57,33,34,16,30,37,27,24,33,44,23,55,46,34];const Numbers=[0,54,34,51,49,31,27,89,26,23,36,35,16,33,45,41,35,28,32,22,29,35,41,30,25,19,65,23,31,39,17,54,42,56,29,34,13];const Deuteronomy=[0,46,37,29,49,30,25,26,20,29,22,32,31,19,29,23,22,20,22,21,20,23,29,26,22,19,19,26,69,28,20,30,52,29,12];const Joshua=[0,18,24,17,24,15,27,26,35,27,43,23,24,33,15,63,10,18,28,51,9,45,34,16,33];const Judges=[0,36,23,31,24,31,40,25,35,57,18,40,15,25,20,20,31,13,31,30,48,25];const Ruth=[0,22,23,18,22];const Isaiah=[0,31,22,26,6,30,13,25,23,20,34,16,6,22,32,9,14,14,7,25,6,17,25,18,23,12,21,13,29,24,33,9,20,24,17,10,22,38,22,8,31,29,25,28,28,25,13,15,22,26,11,23,15,12,17,13,12,21,14,21,22,11,12,19,11,25,24];const Jeremiah=[0,19,37,25,31,31,30,34,23,25,25,23,17,27,22,21,21,27,23,15,18,14,30,40,10,38,24,22,17,32,24,40,44,26,22,19,32,21,28,18,16,18,22,13,30,5,28,7,47,39,46,64,34];const Lamentations=[0,22,22,66,22,22];const Baruch=[0,22,35,38,37,9,72];const Esther=[0,22,23,15,17,14,14,10,17,32,3];const Ecclesiastes=[0,18,26,22,17,19,12,29,17,18,20,10,14];const Ezekiel=[0,28,10,27,17,17,14,27,18,11,22,25,28,23,23,8,63,24,32,14,44,37,31,49,27,17,21,36,26,21,26,18,32,33,31,15,38,28,23,29,49,26,20,27,31,25,24,23,35];const Daniel=[0,21,49,100,34,30,29,28,27,27,21,45,13,64,42];const Hosea=[0,9,25,5,19,15,11,16,14,17,15,11,15,15,10];const Joel=[0,20,27,5,21];const Amos=[0,15,16,15,13,27,14,17,14,15];const Obadiah=[0,21];const Jonah=[0,16,11,10,11];const Micah=[0,16,13,12,14,14,16,20];const Nachum=[0,14,14,19];const Habakkuk=[0,17,20,19];const Zephaniah=[0,18,15,20];const Haggai=[0,15,23];const Zechariah=[0,17,17,10,14,11,15,14,23,17,12,17,14,9,21];const Malachi=[0,14,17,24];var numverses = {Genesis:Genesis,Exodus:Exodus,Leviticus:Leviticus,Numbers:Numbers,Deuteronomy:Deuteronomy,Joshua:Joshua,Judges:Judges,Ruth:Ruth,"I Samuel":[0,28,36,21,22,12,21,17,22,27,27,15,25,23,52,35,23,58,30,24,42,16,23,28,23,43,25,12,25,11,31,13],"II Samuel":[0,27,32,39,12,25,23,29,18,13,19,27,31,39,33,37,23,29,32,44,26,22,51,39,25],"I Kings":[0,53,46,28,20,32,38,51,66,28,29,43,33,34,31,34,34,24,46,21,43,29,54],"II Kings":[0,18,25,27,44,27,33,20,29,37,36,20,22,25,29,38,20,41,37,37,21,26,20,37,20,30],Isaiah:Isaiah,Jeremiah:Jeremiah,Lamentations:Lamentations,Baruch:Baruch,Esther:Esther,Ecclesiastes:Ecclesiastes,"Song of Songs":[0,17,17,11,16,16,12,14,14],Ezekiel:Ezekiel,Daniel:Daniel,Hosea:Hosea,Joel:Joel,Amos:Amos,Obadiah:Obadiah,Jonah:Jonah,Micah:Micah,Nachum:Nachum,Habakkuk:Habakkuk,Zephaniah:Zephaniah,Haggai:Haggai,Zechariah:Zechariah,Malachi:Malachi};
20
+ const Genesis=[0,31,25,24,26,32,22,24,22,29,32,32,20,18,24,21,16,27,33,38,18,34,24,20,67,34,35,46,22,35,43,54,33,20,31,29,43,36,30,23,23,57,38,34,34,28,34,31,22,33,26];const Exodus=[0,22,25,22,31,23,30,29,28,35,29,10,51,22,31,27,36,16,27,25,23,37,30,33,18,40,37,21,43,46,38,18,35,23,35,35,38,29,31,43,38];const Leviticus=[0,17,16,17,35,26,23,38,36,24,20,47,8,59,57,33,34,16,30,37,27,24,33,44,23,55,46,34];const Numbers=[0,54,34,51,49,31,27,89,26,23,36,35,16,33,45,41,35,28,32,22,29,35,41,30,25,19,65,23,31,39,17,54,42,56,29,34,13];const Deuteronomy=[0,46,37,29,49,30,25,26,20,29,22,32,31,19,29,23,22,20,22,21,20,23,29,26,22,19,19,26,69,28,20,30,52,29,12];const Joshua=[0,18,24,17,24,15,27,26,35,27,43,23,24,33,15,63,10,18,28,51,9,45,34,16,33];const Judges=[0,36,23,31,24,31,40,25,35,57,18,40,15,25,20,20,31,13,31,30,48,25];const Ruth=[0,22,23,18,22];const Isaiah=[0,31,22,26,6,30,13,25,23,20,34,16,6,22,32,9,14,14,7,25,6,17,25,18,23,12,21,13,29,24,33,9,20,24,17,10,22,38,22,8,31,29,25,28,28,25,13,15,22,26,11,23,15,12,17,13,12,21,14,21,22,11,12,19,11,25,24];const Jeremiah=[0,19,37,25,31,31,30,34,23,25,25,23,17,27,22,21,21,27,23,15,18,14,30,40,10,38,24,22,17,32,24,40,44,26,22,19,32,21,28,18,16,18,22,13,30,5,28,7,47,39,46,64,34];const Lamentations=[0,22,22,66,22,22];const Baruch=[0,22,35,38,37,9,72];const Esther=[0,22,23,15,17,14,14,10,17,32,3];const Ecclesiastes=[0,18,26,22,17,19,12,29,17,18,20,10,14];const Ezekiel=[0,28,10,27,17,17,14,27,18,11,22,25,28,23,23,8,63,24,32,14,44,37,31,49,27,17,21,36,26,21,26,18,32,33,31,15,38,28,23,29,49,26,20,27,31,25,24,23,35];const Daniel=[0,21,49,100,34,30,29,28,27,27,21,45,13,64,42];const Hosea=[0,9,25,5,19,15,11,16,14,17,15,11,15,15,10];const Joel=[0,20,27,5,21];const Amos=[0,15,16,15,13,27,14,17,14,15];const Obadiah=[0,21];const Jonah=[0,16,11,10,11];const Micah=[0,16,13,12,14,14,16,20];const Nachum=[0,14,14,19];const Habakkuk=[0,17,20,19];const Zephaniah=[0,18,15,20];const Haggai=[0,15,23];const Zechariah=[0,17,17,10,14,11,15,14,23,17,12,17,14,9,21];const Malachi=[0,14,17,24];var numverses = {Genesis:Genesis,Exodus:Exodus,Leviticus:Leviticus,Numbers:Numbers,Deuteronomy:Deuteronomy,Joshua:Joshua,Judges:Judges,Ruth:Ruth,"I Samuel":[0,28,36,21,22,12,21,17,22,27,27,15,25,23,52,35,23,58,30,24,42,16,23,28,23,43,25,12,25,11,31,13],"II Samuel":[0,27,32,39,12,25,23,29,18,13,19,27,31,39,33,37,23,29,32,44,26,22,51,39,25],"I Kings":[0,53,46,28,20,32,38,51,66,28,29,43,33,34,31,34,34,24,46,21,43,29,54],"II Kings":[0,18,25,27,44,27,33,20,29,37,36,20,22,25,29,38,20,41,37,37,21,26,20,37,20,30],Isaiah:Isaiah,Jeremiah:Jeremiah,Lamentations:Lamentations,Baruch:Baruch,Esther:Esther,Ecclesiastes:Ecclesiastes,"Song of Songs":[0,17,17,11,16,16,12,14,14],Ezekiel:Ezekiel,Daniel:Daniel,Hosea:Hosea,Joel:Joel,Amos:Amos,Obadiah:Obadiah,Jonah:Jonah,Micah:Micah,Nachum:Nachum,Habakkuk:Habakkuk,Zephaniah:Zephaniah,Haggai:Haggai,Zechariah:Zechariah,Malachi:Malachi};
21
21
 
22
22
  /**
23
23
  * Names of the books of the Torah. BOOK[1] === 'Genesis'
@@ -64,28 +64,65 @@ function calculateNumVerses(aliyah) {
64
64
  if (aliyah.v) {
65
65
  return aliyah.v;
66
66
  }
67
- const chapVerseBegin = aliyah.b.split(':');
68
- const chapVerseEnd = aliyah.e.split(':');
67
+ aliyah.v = subtractVerses(aliyah.k, aliyah.b, aliyah.e) + 1;
68
+ return aliyah.v;
69
+ }
70
+ /**
71
+ * Finds the number of verses between two locations in the same book.
72
+ * @param book The English name of the book (e.g. "Numbers")
73
+ * @param from The starting verse (e.g. "28:9")
74
+ * @param to The ending verse (e.g. "28:15")
75
+ * @returns The number of verses between the two locations, excluding the `to` verse.
76
+ */
77
+ function subtractVerses(book, from, to) {
78
+ const chapVerseBegin = from.split(':');
79
+ const chapVerseEnd = to.split(':');
69
80
  const c1 = parseInt(chapVerseBegin[0], 10);
70
81
  const c2 = parseInt(chapVerseEnd[0], 10);
71
82
  const v1 = parseInt(chapVerseBegin[1], 10);
72
83
  const v2 = parseInt(chapVerseEnd[1], 10);
84
+ let result = 0;
73
85
  if (c1 === c2) {
74
- aliyah.v = v2 - v1 + 1;
86
+ return v2 - v1;
75
87
  }
76
- else if (typeof aliyah.k === 'string') {
77
- const numv = NUM_VERSES[aliyah.k];
78
- if (typeof numv !== 'object' || !numv.length) {
79
- throw new ReferenceError(`Can't find numverses for ${aliyah.k}`);
80
- }
81
- let total = numv[c1] - v1 + 1;
82
- for (let chap = c1 + 1; chap < c2; chap++) {
83
- total += numv[chap];
84
- }
85
- total += v2;
86
- aliyah.v = total;
88
+ const numv = NUM_VERSES[book];
89
+ if (typeof numv !== 'object' || !numv.length) {
90
+ throw new ReferenceError(`Can't find numverses for ${book}`);
87
91
  }
88
- return aliyah.v;
92
+ let total = numv[c1] - v1;
93
+ for (let chap = c1 + 1; chap < c2; chap++) {
94
+ total += numv[chap];
95
+ }
96
+ total += v2;
97
+ result = total;
98
+ return result;
99
+ }
100
+ /**
101
+ * Calculates the next verse after adding a number of verses to a given location.
102
+ * @param book The English name of the book (e.g. "Numbers")
103
+ * @param from The starting verse (e.g. "28:9")
104
+ * @param numVerses The number of verses to add; must be nonnegative.
105
+ * @returns The next verse after adding the specified number of verses,
106
+ * or null if the resulting verse exceeds the number of verses
107
+ * in the book.
108
+ */
109
+ function addVerses(book, from, numVerses) {
110
+ const chapVerseBegin = from.split(':');
111
+ const c1 = parseInt(chapVerseBegin[0], 10);
112
+ const v1 = parseInt(chapVerseBegin[1], 10);
113
+ const numv = NUM_VERSES[book];
114
+ if (typeof numv !== 'object' || !numv.length) {
115
+ throw new ReferenceError(`Can't find numverses for ${book}`);
116
+ }
117
+ let total = v1 + numVerses;
118
+ let c2 = c1;
119
+ while (total > numv[c2]) {
120
+ total -= numv[c2];
121
+ c2++;
122
+ if (!numv[c2])
123
+ return null;
124
+ }
125
+ return `${c2}:${total}`;
89
126
  }
90
127
  /**
91
128
  * Formats an aliyah object like "Numbers 28:9-28:15"
@@ -254,7 +291,7 @@ function lookupFestival(holiday) {
254
291
  return result;
255
292
  }
256
293
 
257
- /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
294
+ /*! @hebcal/hdate v0.14.0, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
258
295
  /* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
259
296
  /** @private */
260
297
  const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@@ -343,6 +380,9 @@ function greg2abs(date) {
343
380
  if (!isDate(date)) {
344
381
  throw new TypeError(`not a Date: ${date}`);
345
382
  }
383
+ else if (isNaN(date.getTime())) {
384
+ throw new RangeError('Invalid Date');
385
+ }
346
386
  const abs = toFixed(date.getFullYear(), date.getMonth() + 1, date.getDate());
347
387
  /*
348
388
  if (abs < ABS_14SEP1752 && abs > ABS_2SEP1752) {
@@ -371,7 +411,7 @@ function greg2abs(date) {
371
411
  * const day = date.getDate(); // 13
372
412
  */
373
413
  function abs2greg(abs) {
374
- if (typeof abs !== 'number') {
414
+ if (typeof abs !== 'number' || isNaN(abs)) {
375
415
  throw new TypeError(`not a Number: ${abs}`);
376
416
  }
377
417
  abs = Math.trunc(abs);
@@ -392,7 +432,7 @@ function abs2greg(abs) {
392
432
  return dt;
393
433
  }
394
434
 
395
- /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
435
+ /*! @hebcal/hdate v0.14.0, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
396
436
 
397
437
  /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-namespace */
398
438
  /**
@@ -407,7 +447,7 @@ greg.greg2abs = greg2abs;
407
447
  greg.isDate = isDate;
408
448
  greg.isLeapYear = isGregLeapYear;
409
449
 
410
- /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
450
+ /*! @hebcal/hdate v0.14.0, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
411
451
  /*
412
452
  * More minimal HDate
413
453
  */
@@ -773,7 +813,7 @@ function monthFromName(monthName) {
773
813
  throw new RangeError(`bad monthName: ${monthName}`);
774
814
  }
775
815
 
776
- /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
816
+ /*! @hebcal/hdate v0.14.0, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
777
817
  const GERESH = '׳';
778
818
  const GERSHAYIM = '״';
779
819
  const heb2num = {
@@ -886,13 +926,13 @@ function gematriyaStrToNum(str) {
886
926
  return num;
887
927
  }
888
928
 
889
- /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
929
+ /*! @hebcal/hdate v0.14.0, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
890
930
  var poAshkenazi = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);", "language": "en_CA@ashkenazi" }, "contexts": { "": { "Tevet": ["Teves"] } } };
891
931
 
892
- /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
932
+ /*! @hebcal/hdate v0.14.0, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
893
933
  var poHe = { "headers": { "plural-forms": "nplurals=2; plural=(n > 1);", "language": "he" }, "contexts": { "": { "Adar": ["אַדָר"], "Adar I": ["אַדָר א׳"], "Adar II": ["אַדָר ב׳"], "Av": ["אָב"], "Cheshvan": ["חֶשְׁוָן"], "Elul": ["אֱלוּל"], "Iyyar": ["אִיָיר"], "Kislev": ["כִּסְלֵו"], "Nisan": ["נִיסָן"], "Sh'vat": ["שְׁבָט"], "Sivan": ["סִיוָן"], "Tamuz": ["תַּמּוּז"], "Tevet": ["טֵבֵת"], "Tishrei": ["תִּשְׁרֵי"] } } };
894
934
 
895
- /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
935
+ /*! @hebcal/hdate v0.14.0, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
896
936
 
897
937
  const noopLocale = {
898
938
  headers: { 'plural-forms': 'nplurals=2; plural=(n!=1);' },
@@ -1102,7 +1142,7 @@ const poHeNoNikud = {
1102
1142
  };
1103
1143
  Locale.addLocale('he-x-NoNikud', poHeNoNikud);
1104
1144
 
1105
- /*! @hebcal/hdate v0.13.5, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1145
+ /*! @hebcal/hdate v0.14.0, distributed under GPLv2 https://www.gnu.org/licenses/gpl-2.0.txt */
1106
1146
 
1107
1147
  /*
1108
1148
  Hebcal - A Jewish Calendar Generator
@@ -2160,9 +2200,7 @@ function getLeyningForHolidayKey(key, cholHaMoedDay, il) {
2160
2200
  if (typeof leyning.fullkriyah['1'] === 'object') {
2161
2201
  const parts = makeLeyningParts(leyning.fullkriyah);
2162
2202
  leyning.summary = makeSummaryFromParts(parts);
2163
- if (parts.length > 1) {
2164
- leyning.summaryParts = parts;
2165
- }
2203
+ leyning.summaryParts = parts;
2166
2204
  }
2167
2205
  Object.values(leyning.fullkriyah).map(aliyah => calculateNumVerses(aliyah));
2168
2206
  }
@@ -2187,9 +2225,14 @@ function getLeyningForHolidayKey(key, cholHaMoedDay, il) {
2187
2225
  m[`${i}`] = { k: megillah, b: `${i}:1`, e: `${i}:${numv}`, v: numv };
2188
2226
  }
2189
2227
  leyning.megillah = m;
2228
+ const parts = makeLeyningParts(m);
2229
+ if (leyning.summaryParts) {
2230
+ leyning.summaryParts.push(...parts);
2231
+ }
2232
+ const megillahSummary = makeSummaryFromParts(parts);
2190
2233
  leyning.summary = leyning.summary
2191
- ? leyning.summary + '; ' + megillah
2192
- : megillah;
2234
+ ? leyning.summary + '; ' + megillahSummary
2235
+ : megillahSummary;
2193
2236
  }
2194
2237
  if (src.note) {
2195
2238
  leyning.note = src.note;
@@ -2546,6 +2589,7 @@ get: function () { return locale.Locale; }
2546
2589
  });
2547
2590
  exports.BOOK = BOOK;
2548
2591
  exports.NUM_VERSES = NUM_VERSES;
2592
+ exports.addVerses = addVerses;
2549
2593
  exports.calculateNumVerses = calculateNumVerses;
2550
2594
  exports.clone = clone;
2551
2595
  exports.cloneHaftara = cloneHaftara;
@@ -2567,6 +2611,7 @@ exports.makeLeyningSummary = makeLeyningSummary;
2567
2611
  exports.makeSummaryFromParts = makeSummaryFromParts;
2568
2612
  exports.parshaToString = parshaToString;
2569
2613
  exports.specialReadings2 = specialReadings2;
2614
+ exports.subtractVerses = subtractVerses;
2570
2615
  exports.sumVerses = sumVerses;
2571
2616
 
2572
2617
  return exports;