@hebcal/core 5.4.9 → 5.4.10

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.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v5.4.9 */
1
+ /*! @hebcal/core v5.4.10 */
2
2
  /* eslint-disable @typescript-eslint/no-namespace, no-inner-declarations */
3
3
  /** @private */
4
4
  const lengths = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@@ -9105,7 +9105,7 @@ class Sedra {
9105
9105
  */
9106
9106
  find(parsha) {
9107
9107
  if (typeof parsha === 'number') {
9108
- if (parsha > 53 || (parsha < 0 && !isValidDouble(parsha))) {
9108
+ if (parsha >= parshiot.length || (parsha < 0 && !isValidDouble(parsha))) {
9109
9109
  throw new RangeError(`Invalid parsha number: ${parsha}`);
9110
9110
  }
9111
9111
  const idx = this.theSedraArray.indexOf(parsha);
@@ -9131,29 +9131,27 @@ class Sedra {
9131
9131
  return new HDate(this.firstSaturday + idx * 7);
9132
9132
  }
9133
9133
  }
9134
- else if (Array.isArray(parsha) &&
9135
- parsha.length === 1 &&
9136
- typeof parsha[0] === 'string') {
9137
- return this.find(parsha[0]);
9138
- }
9139
- else if (Array.isArray(parsha) &&
9140
- parsha.length === 2 &&
9141
- typeof parsha[0] === 'string' &&
9142
- typeof parsha[1] === 'string') {
9134
+ else if (Array.isArray(parsha)) {
9135
+ const plen = parsha.length;
9136
+ if ((plen !== 1 && plen !== 2) || typeof parsha[0] !== 'string') {
9137
+ throw new TypeError(`Invalid parsha argument: ${JSON.stringify(parsha)}`);
9138
+ }
9139
+ if (plen === 1) {
9140
+ return this.find(parsha[0]);
9141
+ }
9143
9142
  const p1 = parsha[0];
9144
9143
  const p2 = parsha[1];
9145
9144
  const num1 = parsha2id.get(p1);
9146
9145
  const num2 = parsha2id.get(p2);
9147
- if (num2 === num1 + 1) {
9148
- return this.find(-num1);
9149
- }
9150
- else {
9146
+ if (typeof num1 !== 'number' ||
9147
+ typeof num2 !== 'number' ||
9148
+ num2 !== num1 + 1 ||
9149
+ !isValidDouble(-num1)) {
9151
9150
  throw new RangeError(`Unrecognized parsha name: ${p1}-${p2}`);
9152
9151
  }
9152
+ return this.find(-num1);
9153
9153
  }
9154
- else {
9155
- throw new TypeError(`Invalid parsha argument: ${parsha}`);
9156
- }
9154
+ return null; /* NOTREACHED */
9157
9155
  }
9158
9156
  /**
9159
9157
  * Returns the underlying annual sedra schedule.
@@ -10102,17 +10100,6 @@ const staticModernHolidays = [
10102
10100
  },
10103
10101
  ];
10104
10102
 
10105
- const minorHolidays = [
10106
- holidayDesc.LAG_BAOMER,
10107
- holidayDesc.LEIL_SELICHOT,
10108
- holidayDesc.PESACH_SHENI,
10109
- holidayDesc.EREV_PURIM,
10110
- holidayDesc.PURIM_KATAN,
10111
- holidayDesc.SHUSHAN_PURIM,
10112
- holidayDesc.TU_BAV,
10113
- holidayDesc.TU_BISHVAT,
10114
- holidayDesc.ROSH_HASHANA_LABEHEMOT,
10115
- ];
10116
10103
  /** Represents a built-in holiday like Pesach, Purim or Tu BiShvat */
10117
10104
  class HolidayEvent extends Event {
10118
10105
  basename() {
@@ -10162,8 +10149,17 @@ class HolidayEvent extends Event {
10162
10149
  }
10163
10150
  // Don't depend on flags.MINOR_HOLIDAY always being set. Look for minor holidays.
10164
10151
  const desc = this.getDesc();
10165
- if (minorHolidays.includes(desc)) {
10166
- return ['holiday', 'minor'];
10152
+ switch (desc) {
10153
+ case holidayDesc.LAG_BAOMER:
10154
+ case holidayDesc.LEIL_SELICHOT:
10155
+ case holidayDesc.PESACH_SHENI:
10156
+ case holidayDesc.EREV_PURIM:
10157
+ case holidayDesc.PURIM_KATAN:
10158
+ case holidayDesc.SHUSHAN_PURIM:
10159
+ case holidayDesc.TU_BAV:
10160
+ case holidayDesc.TU_BISHVAT:
10161
+ case holidayDesc.ROSH_HASHANA_LABEHEMOT:
10162
+ return ['holiday', 'minor'];
10167
10163
  }
10168
10164
  return ['holiday', 'major'];
10169
10165
  }
@@ -10341,7 +10337,7 @@ class DailyLearning {
10341
10337
  }
10342
10338
 
10343
10339
  /** DO NOT EDIT THIS AUTO-GENERATED FILE! */
10344
- const version = '5.4.9';
10340
+ const version = '5.4.10';
10345
10341
 
10346
10342
  /* eslint-disable max-len */
10347
10343
  /**
@@ -11386,6 +11382,7 @@ function observedInDiaspora(ev) {
11386
11382
  * Event names can be rendered in several languges using the `locale` option.
11387
11383
  */
11388
11384
  class HebrewCalendar {
11385
+ constructor() { }
11389
11386
  /**
11390
11387
  * Calculates holidays and other Hebrew calendar events based on {@link CalOptions}.
11391
11388
  *