@hebcal/core 6.0.6 → 6.0.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.
Files changed (142) hide show
  1. package/README.md +42 -27
  2. package/dist/bundle.js +13 -8
  3. package/dist/bundle.js.map +1 -1
  4. package/dist/bundle.min.js +3 -3
  5. package/dist/bundle.min.js.map +1 -1
  6. package/dist/esm/DailyLearning.js +1 -1
  7. package/dist/esm/HebrewDateEvent.js +1 -1
  8. package/dist/esm/HolidayEvent.js +1 -1
  9. package/dist/esm/MevarchimChodeshEvent.js +1 -1
  10. package/dist/esm/ParshaEvent.js +1 -1
  11. package/dist/esm/TimedEvent.js +1 -1
  12. package/dist/esm/YomKippurKatanEvent.js +1 -1
  13. package/dist/esm/ashkenazi.po.js +1 -1
  14. package/dist/esm/calendar.js +1 -1
  15. package/dist/esm/candles.js +1 -1
  16. package/dist/esm/event.js +1 -1
  17. package/dist/esm/getStartAndEnd.js +1 -1
  18. package/dist/esm/hallel.js +1 -1
  19. package/dist/esm/he-x-NoNikud.po.d.ts +3 -0
  20. package/dist/esm/he-x-NoNikud.po.js +2 -2
  21. package/dist/esm/he-x-NoNikud.po.js.map +1 -1
  22. package/dist/esm/he.po.d.ts +1 -0
  23. package/dist/esm/he.po.js +2 -2
  24. package/dist/esm/he.po.js.map +1 -1
  25. package/dist/esm/hebcal.js +1 -1
  26. package/dist/esm/holidays.js +1 -1
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/isAssurBemlacha.js +1 -1
  29. package/dist/esm/locale.js +1 -1
  30. package/dist/esm/location.js +2 -2
  31. package/dist/esm/location.js.map +1 -1
  32. package/dist/esm/modern.js +1 -1
  33. package/dist/esm/molad.js +1 -1
  34. package/dist/esm/omer.js +1 -1
  35. package/dist/esm/parshaName.js +1 -1
  36. package/dist/esm/parshaYear.d.ts +2 -2
  37. package/dist/esm/parshaYear.js +1 -1
  38. package/dist/esm/parshaYear.js.map +1 -1
  39. package/dist/esm/pkgVersion.d.ts +1 -1
  40. package/dist/esm/pkgVersion.js +2 -2
  41. package/dist/esm/pkgVersion.js.map +1 -1
  42. package/dist/esm/reformatTimeStr.js +1 -1
  43. package/dist/esm/sedra.d.ts +5 -1
  44. package/dist/esm/sedra.js +9 -3
  45. package/dist/esm/sedra.js.map +1 -1
  46. package/dist/esm/staticHolidays.js +1 -2
  47. package/dist/esm/staticHolidays.js.map +1 -1
  48. package/dist/esm/tachanun.js +1 -1
  49. package/dist/esm/zmanim.js +1 -1
  50. package/dist/he-x-NoNikud.po.d.ts +3 -0
  51. package/dist/he.po.d.ts +1 -0
  52. package/dist/parshaYear.d.ts +2 -2
  53. package/dist/pkgVersion.d.ts +1 -1
  54. package/dist/po2json.d.ts +1 -0
  55. package/dist/po2json.js +41 -0
  56. package/dist/sedra.d.ts +5 -1
  57. package/dist/size-demo/dist/getHoliday.d.ts +1944 -0
  58. package/dist/size-demo/dist/getHoliday.js +3712 -0
  59. package/dist/size-demo/dist/parshiyot.js +10662 -0
  60. package/dist/size-demo/dist/sedra.d.ts +1411 -0
  61. package/dist/size-demo/dist/sedra.js +2359 -0
  62. package/dist/size-demo/dist/tachanun.d.ts +1015 -0
  63. package/dist/size-demo/dist/tachanun.js +1755 -0
  64. package/dist/size-demo/getHoliday.d.ts +1 -0
  65. package/dist/size-demo/getHoliday.js +3 -0
  66. package/dist/size-demo/parshiyot.d.ts +1 -0
  67. package/dist/size-demo/parshiyot.js +11 -0
  68. package/dist/size-demo/rollup.config.d.ts +3 -0
  69. package/dist/size-demo/rollup.config.js +47 -0
  70. package/dist/size-demo/sedra.d.ts +1 -0
  71. package/dist/size-demo/sedra.js +3 -0
  72. package/dist/size-demo/tachanun.d.ts +1 -0
  73. package/dist/size-demo/tachanun.js +3 -0
  74. package/dist/src/CalOptions.d.ts +168 -0
  75. package/dist/src/CalOptions.js +1 -0
  76. package/dist/src/DailyLearning.d.ts +32 -0
  77. package/dist/src/DailyLearning.js +55 -0
  78. package/dist/src/HebrewDateEvent.d.ts +37 -0
  79. package/dist/src/HebrewDateEvent.js +72 -0
  80. package/dist/src/HolidayEvent.d.ts +83 -0
  81. package/dist/src/HolidayEvent.js +186 -0
  82. package/dist/src/MevarchimChodeshEvent.d.ts +26 -0
  83. package/dist/src/MevarchimChodeshEvent.js +50 -0
  84. package/dist/src/ParshaEvent.d.ts +19 -0
  85. package/dist/src/ParshaEvent.js +43 -0
  86. package/dist/src/TimedEvent.d.ts +47 -0
  87. package/dist/src/TimedEvent.js +92 -0
  88. package/dist/src/YomKippurKatanEvent.d.ts +23 -0
  89. package/dist/src/YomKippurKatanEvent.js +38 -0
  90. package/dist/src/ashkenazi.po.d.ts +70 -0
  91. package/dist/src/ashkenazi.po.js +1 -0
  92. package/dist/src/calendar.d.ts +111 -0
  93. package/dist/src/calendar.js +660 -0
  94. package/dist/src/candles.d.ts +44 -0
  95. package/dist/src/candles.js +163 -0
  96. package/dist/src/event.d.ts +188 -0
  97. package/dist/src/event.js +233 -0
  98. package/dist/src/getStartAndEnd.d.ts +6 -0
  99. package/dist/src/getStartAndEnd.js +97 -0
  100. package/dist/src/hallel.d.ts +6 -0
  101. package/dist/src/hallel.js +47 -0
  102. package/dist/src/he-x-NoNikud.po.d.ts +16 -0
  103. package/dist/src/he-x-NoNikud.po.js +1 -0
  104. package/dist/src/he.po.d.ts +195 -0
  105. package/dist/src/he.po.js +1 -0
  106. package/dist/src/hebcal.d.ts +260 -0
  107. package/dist/src/hebcal.js +332 -0
  108. package/dist/src/holidays.d.ts +22 -0
  109. package/dist/src/holidays.js +288 -0
  110. package/dist/src/index.d.ts +26 -0
  111. package/dist/src/index.js +24 -0
  112. package/dist/src/isAssurBemlacha.d.ts +9 -0
  113. package/dist/src/isAssurBemlacha.js +62 -0
  114. package/dist/src/locale.d.ts +2 -0
  115. package/dist/src/locale.js +11 -0
  116. package/dist/src/location.d.ts +73 -0
  117. package/dist/src/location.js +306 -0
  118. package/dist/src/modern.d.ts +18 -0
  119. package/dist/src/modern.js +59 -0
  120. package/dist/src/molad.d.ts +62 -0
  121. package/dist/src/molad.js +169 -0
  122. package/dist/src/omer.d.ts +53 -0
  123. package/dist/src/omer.js +302 -0
  124. package/dist/src/parshaName.d.ts +2 -0
  125. package/dist/src/parshaName.js +13 -0
  126. package/dist/src/parshaYear.d.ts +9 -0
  127. package/dist/src/parshaYear.js +24 -0
  128. package/dist/src/pkgVersion.d.ts +2 -0
  129. package/dist/src/pkgVersion.js +2 -0
  130. package/dist/src/reformatTimeStr.d.ts +8 -0
  131. package/dist/src/reformatTimeStr.js +48 -0
  132. package/dist/src/sedra.d.ts +95 -0
  133. package/dist/src/sedra.js +477 -0
  134. package/dist/src/staticHolidays.d.ts +176 -0
  135. package/dist/src/staticHolidays.js +614 -0
  136. package/dist/src/tachanun.d.ts +29 -0
  137. package/dist/src/tachanun.js +120 -0
  138. package/dist/src/zmanim.d.ts +347 -0
  139. package/dist/src/zmanim.js +579 -0
  140. package/dist/version.d.ts +1 -0
  141. package/dist/version.js +9 -0
  142. package/package.json +11 -8
@@ -0,0 +1,95 @@
1
+ import { HDate } from '@hebcal/hdate';
2
+ import './locale';
3
+ /** The result from `Sedra.lookup()` */
4
+ export type SedraResult = {
5
+ /**
6
+ * Name of the parsha (or parshiyot) read on
7
+ * Hebrew date, e.g. `['Noach']` or `['Matot', 'Masei']`
8
+ */
9
+ parsha: string[];
10
+ /**
11
+ * False if this is a regular parashat HaShavua reading.
12
+ * True if it's a special holiday reading.
13
+ */
14
+ chag: boolean;
15
+ /**
16
+ * The parsha number (or numbers) using 1-indexing.
17
+ * A `number` for a regular (single) parsha, and a `number[]`
18
+ * for a doubled parsha.
19
+ * For Parashat *Bereshit*, `num` would be equal to `1`, and for
20
+ * *Matot-Masei* it would be `[42, 43]`
21
+ * For a chag (holiday) reading, `num` will be `0`.
22
+ */
23
+ num: number | number[];
24
+ /** The date of the Shabbat this parsha is read */
25
+ hdate: HDate;
26
+ /** true if Israel, false for Diaspora */
27
+ il: boolean;
28
+ };
29
+ /**
30
+ * Represents Parashah HaShavua for an entire Hebrew year
31
+ */
32
+ export declare class Sedra {
33
+ private readonly year;
34
+ private readonly il;
35
+ private readonly rh;
36
+ private readonly firstSaturday;
37
+ private readonly theSedraArray;
38
+ private readonly yearKey;
39
+ /**
40
+ * Caculates the Parashah HaShavua for an entire Hebrew year
41
+ * @param hyear - Hebrew year (e.g. 5749)
42
+ * @param il - Use Israel sedra schedule (false for Diaspora)
43
+ */
44
+ constructor(hyear: number, il: boolean);
45
+ /**
46
+ * Returns the date that a parsha occurs
47
+ * or `null` if the parsha doesn't occur this year
48
+ * @param parsha if a `string`, specified with Sephardic transliterations
49
+ * like `'Noach'` or `'Matot-Masei'`. If an array, must be a 1- or 2-element
50
+ * array such as `['Noach']` or `['Matot', 'Masei']`. If a `number`, should
51
+ * be a 0-based parsha index (`0` for Bereshit, `1` for Noach) or a negative
52
+ * number for a doubled parsha (e.g. `-21` for Vayakhel-Pekudei)
53
+ */
54
+ find(parsha: number | string | string[]): HDate | null;
55
+ private findInternal;
56
+ /**
57
+ * Returns the date that a parsha (or its doubled or undoubled counterpart)
58
+ * occurs, or `null` if the parsha doesn't occur this year
59
+ */
60
+ findContaining(parsha: number | string): HDate | null;
61
+ /**
62
+ * Returns the underlying annual sedra schedule.
63
+ * Used by `@hebcal/triennial`
64
+ */
65
+ getSedraArray(): readonly NumberOrString[];
66
+ /**
67
+ * R.D. date of the first Saturday on or after Rosh Hashana
68
+ */
69
+ getFirstSaturday(): number;
70
+ getYear(): number;
71
+ /**
72
+ * Returns an object describing the parsha on the first Saturday on or after `hd`
73
+ * @param hd Hebrew date or R.D. days
74
+ */
75
+ lookup(hd: HDate | number): SedraResult;
76
+ }
77
+ /**
78
+ * The 54 parshiyot of the Torah as transilterated strings.
79
+ * * parshiot[0] == `Bereshit`
80
+ * * parshiot[1] == `Noach`
81
+ * * parshiot[52] == `Ha'azinu`
82
+ * * parshiot[53] == `Vezot Haberakhah`
83
+ * @readonly
84
+ * @type {string[]}
85
+ */
86
+ export declare const parshiot: readonly string[];
87
+ type NumberOrString = number | string;
88
+ /**
89
+ * Convenience function to create an instance of `Sedra` or reuse a previously
90
+ * created and cached instance.
91
+ * @param hyear
92
+ * @param il
93
+ */
94
+ export declare function getSedra(hyear: number, il: boolean): Sedra;
95
+ export {};
@@ -0,0 +1,477 @@
1
+ /*
2
+ Hebcal - A Jewish Calendar Generator
3
+ Copyright (c) 1994-2020 Danny Sadinoff
4
+ Portions copyright Eyal Schachter and Michael J. Radwin
5
+
6
+ https://github.com/hebcal/hebcal-es6
7
+
8
+ This program is free software; you can redistribute it and/or
9
+ modify it under the terms of the GNU General Public License
10
+ as published by the Free Software Foundation; either version 2
11
+ of the License, or (at your option) any later version.
12
+
13
+ This program is distributed in the hope that it will be useful,
14
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ GNU General Public License for more details.
17
+
18
+ You should have received a copy of the GNU General Public License
19
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+ */
21
+ /*
22
+ * Many of the following algorithms were taken from hebrew calendar
23
+ * routines by Maimonedes, from his Mishneh Torah, and implemented by
24
+ * Nachum Dershowitz Department of Computer Science
25
+ * (217) 333-4219 University of Illinois at Urbana-Champaign
26
+ * nachum@cs.uiuedu 1304 West Springfield Avenue
27
+ * Urbana, Illinois 61801
28
+ *
29
+ * The routines were included in the emacs 19 distribution.
30
+ *
31
+ */
32
+ import { HDate, months } from '@hebcal/hdate';
33
+ import QuickLRU from 'quick-lru';
34
+ import './locale'; // Adds Hebrew and Ashkenazic translations
35
+ const INCOMPLETE = 0;
36
+ const REGULAR = 1;
37
+ const COMPLETE = 2;
38
+ function yearType(hyear) {
39
+ const longC = HDate.longCheshvan(hyear);
40
+ const shortK = HDate.shortKislev(hyear);
41
+ if (longC && !shortK) {
42
+ return COMPLETE;
43
+ }
44
+ else if (!longC && shortK) {
45
+ return INCOMPLETE;
46
+ }
47
+ else {
48
+ return REGULAR;
49
+ }
50
+ }
51
+ /**
52
+ * Represents Parashah HaShavua for an entire Hebrew year
53
+ */
54
+ export class Sedra {
55
+ /**
56
+ * Caculates the Parashah HaShavua for an entire Hebrew year
57
+ * @param hyear - Hebrew year (e.g. 5749)
58
+ * @param il - Use Israel sedra schedule (false for Diaspora)
59
+ */
60
+ constructor(hyear, il) {
61
+ hyear = +hyear;
62
+ this.year = hyear;
63
+ const rh0 = new HDate(1, months.TISHREI, hyear);
64
+ const rh = (this.rh = rh0.abs());
65
+ const rhDay = rh0.getDay() + 1;
66
+ // find the first Saturday on or after Rosh Hashana
67
+ this.firstSaturday = HDate.dayOnOrBefore(6, rh + 6);
68
+ const leap = +HDate.isLeapYear(hyear);
69
+ this.il = Boolean(il);
70
+ const type = yearType(hyear);
71
+ let key = `${leap}${rhDay}${type}`;
72
+ if (types[key]) {
73
+ this.theSedraArray = types[key];
74
+ this.yearKey = key;
75
+ }
76
+ else {
77
+ key = key + +this.il; // cast to num, then concat
78
+ this.theSedraArray = types[key];
79
+ this.yearKey = key;
80
+ }
81
+ if (!this.theSedraArray) {
82
+ throw new Error(`improper sedra year type ${key} calculated for ${hyear}`);
83
+ }
84
+ }
85
+ /**
86
+ * Returns the date that a parsha occurs
87
+ * or `null` if the parsha doesn't occur this year
88
+ * @param parsha if a `string`, specified with Sephardic transliterations
89
+ * like `'Noach'` or `'Matot-Masei'`. If an array, must be a 1- or 2-element
90
+ * array such as `['Noach']` or `['Matot', 'Masei']`. If a `number`, should
91
+ * be a 0-based parsha index (`0` for Bereshit, `1` for Noach) or a negative
92
+ * number for a doubled parsha (e.g. `-21` for Vayakhel-Pekudei)
93
+ */
94
+ find(parsha) {
95
+ if (typeof parsha === 'number') {
96
+ if (parsha >= parshiot.length || (parsha < 0 && !isValidDouble(parsha))) {
97
+ throw new RangeError(`Invalid parsha number: ${parsha}`);
98
+ }
99
+ return this.findInternal(parsha);
100
+ }
101
+ else if (typeof parsha === 'string') {
102
+ const num = parsha2id.get(parsha);
103
+ if (typeof num === 'number') {
104
+ return this.find(num);
105
+ }
106
+ else if (parsha.indexOf('-') !== -1) {
107
+ if (parsha === CHMPESACH || parsha === CHMSUKOT) {
108
+ return this.findInternal(parsha);
109
+ }
110
+ return this.find(parsha.split('-'));
111
+ }
112
+ else {
113
+ // try to find Saturday holiday like 'Yom Kippur'
114
+ return this.findInternal(parsha);
115
+ }
116
+ }
117
+ else if (Array.isArray(parsha)) {
118
+ const plen = parsha.length;
119
+ if ((plen !== 1 && plen !== 2) || typeof parsha[0] !== 'string') {
120
+ throw new TypeError(`Invalid parsha argument: ${JSON.stringify(parsha)}`);
121
+ }
122
+ if (plen === 1) {
123
+ return this.find(parsha[0]);
124
+ }
125
+ const p1 = parsha[0];
126
+ const p2 = parsha[1];
127
+ const num1 = parsha2id.get(p1);
128
+ const num2 = parsha2id.get(p2);
129
+ if (typeof num1 !== 'number' ||
130
+ typeof num2 !== 'number' ||
131
+ num2 !== num1 + 1 ||
132
+ !isValidDouble(-num1)) {
133
+ throw new RangeError(`Unrecognized parsha name: ${p1}-${p2}`);
134
+ }
135
+ return this.find(-num1);
136
+ }
137
+ return null; /* NOTREACHED */
138
+ }
139
+ findInternal(parsha) {
140
+ const idx = this.theSedraArray.indexOf(parsha);
141
+ if (idx === -1) {
142
+ return null; // doesn't occur this year
143
+ }
144
+ return new HDate(this.firstSaturday + idx * 7);
145
+ }
146
+ /**
147
+ * Returns the date that a parsha (or its doubled or undoubled counterpart)
148
+ * occurs, or `null` if the parsha doesn't occur this year
149
+ */
150
+ findContaining(parsha) {
151
+ const hdate = this.find(parsha);
152
+ if (hdate) {
153
+ return hdate;
154
+ }
155
+ if (typeof parsha === 'number') {
156
+ // a valid negative number (double parsha in a year where they are
157
+ // combined) would've been found above, and a invalid negative number
158
+ // would've thrown an error, so this parsha must be a positive number
159
+ // representing either p1 or p2
160
+ const p1 = -parsha;
161
+ if (isValidDouble(p1)) {
162
+ return this.find(p1);
163
+ }
164
+ else {
165
+ // this must be the second individual parsha of a doubled pair
166
+ // for example 29 for Kedoshim, so check for -28 for Achrei Mot-Kedoshim
167
+ return this.find(p1 + 1);
168
+ }
169
+ }
170
+ else {
171
+ const num = parsha2id.get(parsha);
172
+ if (num) {
173
+ // parsha is either the first or second individual parsha of
174
+ // a pair that is doubled this year
175
+ const p1 = -num;
176
+ if (isValidDouble(p1)) {
177
+ return this.find(p1);
178
+ }
179
+ else {
180
+ return this.find(p1 + 1);
181
+ }
182
+ }
183
+ else {
184
+ // this was indeed a doubled parsha, so return date of the first half
185
+ const [p1] = parsha.split('-');
186
+ return this.find(p1);
187
+ }
188
+ }
189
+ }
190
+ /**
191
+ * Returns the underlying annual sedra schedule.
192
+ * Used by `@hebcal/triennial`
193
+ */
194
+ getSedraArray() {
195
+ return this.theSedraArray;
196
+ }
197
+ /**
198
+ * R.D. date of the first Saturday on or after Rosh Hashana
199
+ */
200
+ getFirstSaturday() {
201
+ return this.firstSaturday;
202
+ }
203
+ getYear() {
204
+ return this.year;
205
+ }
206
+ /**
207
+ * Returns an object describing the parsha on the first Saturday on or after `hd`
208
+ * @param hd Hebrew date or R.D. days
209
+ */
210
+ lookup(hd) {
211
+ const abs = typeof hd === 'number' ? hd : HDate.isHDate(hd) ? hd.abs() : NaN;
212
+ if (isNaN(abs)) {
213
+ throw new TypeError(`Bad date argument: ${hd}`);
214
+ }
215
+ else if (abs < this.rh) {
216
+ throw new RangeError(`Date ${hd} before start of Hebrew year ${this.year}`);
217
+ }
218
+ // find the first saturday on or after today's date
219
+ const saturday = HDate.dayOnOrBefore(6, abs + 6);
220
+ const weekNum = (saturday - this.firstSaturday) / 7;
221
+ const index = this.theSedraArray[weekNum];
222
+ if (typeof index === 'undefined') {
223
+ const sedra = getSedra(this.year + 1, this.il);
224
+ return sedra.lookup(saturday); // must be next year
225
+ }
226
+ const hdate = new HDate(saturday);
227
+ if (typeof index === 'string') {
228
+ // Shabbat has a chag. Return a description
229
+ return { parsha: [index], chag: true, hdate, il: this.il, num: 0 };
230
+ }
231
+ if (index >= 0) {
232
+ return {
233
+ parsha: [parshiot[index]],
234
+ chag: false,
235
+ num: index + 1,
236
+ hdate,
237
+ il: this.il,
238
+ };
239
+ }
240
+ const p1 = D(index); // undouble the parsha
241
+ return {
242
+ parsha: [parshiot[p1], parshiot[p1 + 1]],
243
+ chag: false,
244
+ num: [p1 + 1, p1 + 2],
245
+ hdate,
246
+ il: this.il,
247
+ };
248
+ }
249
+ }
250
+ /**
251
+ * The 54 parshiyot of the Torah as transilterated strings.
252
+ * * parshiot[0] == `Bereshit`
253
+ * * parshiot[1] == `Noach`
254
+ * * parshiot[52] == `Ha'azinu`
255
+ * * parshiot[53] == `Vezot Haberakhah`
256
+ * @readonly
257
+ * @type {string[]}
258
+ */
259
+ export const parshiot = [
260
+ 'Bereshit',
261
+ 'Noach',
262
+ 'Lech-Lecha',
263
+ 'Vayera',
264
+ 'Chayei Sara',
265
+ 'Toldot',
266
+ 'Vayetzei',
267
+ 'Vayishlach',
268
+ 'Vayeshev',
269
+ 'Miketz',
270
+ 'Vayigash',
271
+ 'Vayechi',
272
+ 'Shemot',
273
+ 'Vaera',
274
+ 'Bo',
275
+ 'Beshalach',
276
+ 'Yitro',
277
+ 'Mishpatim',
278
+ 'Terumah',
279
+ 'Tetzaveh',
280
+ 'Ki Tisa',
281
+ 'Vayakhel',
282
+ 'Pekudei',
283
+ 'Vayikra',
284
+ 'Tzav',
285
+ 'Shmini',
286
+ 'Tazria',
287
+ 'Metzora',
288
+ 'Achrei Mot',
289
+ 'Kedoshim',
290
+ 'Emor',
291
+ 'Behar',
292
+ 'Bechukotai',
293
+ 'Bamidbar',
294
+ 'Nasso',
295
+ "Beha'alotcha",
296
+ "Sh'lach",
297
+ 'Korach',
298
+ 'Chukat',
299
+ 'Balak',
300
+ 'Pinchas',
301
+ 'Matot',
302
+ 'Masei',
303
+ 'Devarim',
304
+ 'Vaetchanan',
305
+ 'Eikev',
306
+ "Re'eh",
307
+ 'Shoftim',
308
+ 'Ki Teitzei',
309
+ 'Ki Tavo',
310
+ 'Nitzavim',
311
+ 'Vayeilech',
312
+ "Ha'azinu",
313
+ 'Vezot Haberakhah',
314
+ ];
315
+ // 0-based parsha IDs
316
+ const parsha2id = new Map();
317
+ for (let id = 0; id < parshiot.length; id++) {
318
+ const name = parshiot[id];
319
+ parsha2id.set(name, id);
320
+ }
321
+ // 0-based parsha IDs
322
+ const doubles = [
323
+ 21, // Vayakhel-Pekudei
324
+ 26, // Tazria-Metzora
325
+ 28, // Achrei Mot-Kedoshim
326
+ 31, // Behar-Bechukotai
327
+ 38, // Chukat-Balak
328
+ 41, // Matot-Masei
329
+ 50, // Nitzavim-Vayeilech
330
+ ];
331
+ /**
332
+ * @private
333
+ * @param id a negative number
334
+ */
335
+ function isValidDouble(id) {
336
+ return doubles.includes(-id);
337
+ }
338
+ /**
339
+ * parsha doubler/undoubler
340
+ * @private
341
+ * @param p
342
+ */
343
+ function D(p) {
344
+ return -p;
345
+ }
346
+ const RH = 'Rosh Hashana'; // 0
347
+ const YK = 'Yom Kippur'; // 1
348
+ const SUKKOT = 'Sukkot'; // 0
349
+ const CHMSUKOT = 'Sukkot Shabbat Chol ha-Moed'; // 0
350
+ const SHMINI = 'Shmini Atzeret'; // 0
351
+ const PESACH = 'Pesach'; // 25
352
+ const PESACH1 = 'Pesach I';
353
+ const CHMPESACH = 'Pesach Shabbat Chol ha-Moed'; // 25
354
+ const PESACH7 = 'Pesach VII'; // 25
355
+ const PESACH8 = 'Pesach VIII';
356
+ const SHAVUOT = 'Shavuot'; // 33
357
+ /**
358
+ * Returns an array from start to end
359
+ * @private
360
+ * @param start beginning number, inclusive
361
+ * @param stop ending number, inclusive
362
+ */
363
+ function range(start, stop) {
364
+ return Array.from({ length: stop - start + 1 }, (v, k) => k + start);
365
+ }
366
+ const yearStartVayeilech = [51, 52, CHMSUKOT];
367
+ const yearStartHaazinu = [52, YK, CHMSUKOT];
368
+ const yearStartRH = [RH, 52, SUKKOT, SHMINI];
369
+ const r020 = range(0, 20);
370
+ const r027 = range(0, 27);
371
+ const r3340 = range(33, 40);
372
+ const r4349 = range(43, 49);
373
+ const r4350 = range(43, 50);
374
+ /**
375
+ * The ordinary year types (keviot)
376
+ * names are leap/nonleap - day - incomplete/regular/complete - diaspora/Israel
377
+ * @private
378
+ * @readonly
379
+ */
380
+ const types = {
381
+ /* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
382
+ * Kislev each have 29 days), and has Passover start on Tuesday. */
383
+ // e.g. 5753
384
+ '020': yearStartVayeilech.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), r3340, D(41), r4349, D(50)),
385
+ /* Hebrew year that starts on Monday, is `complete' (Heshvan and
386
+ * Kislev each have 30 days), and has Passover start on Thursday. */
387
+ // e.g. 5756
388
+ '0220': yearStartVayeilech.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), 33, SHAVUOT, range(34, 37), D(38), 40, D(41), r4349, D(50)),
389
+ /* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
390
+ * days and Kislev has 30 days), and has Passover start on Saturday. */
391
+ // e.g. 5701
392
+ '0510': yearStartHaazinu.concat(r020, D(21), 23, 24, PESACH1, PESACH8, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
393
+ /* Hebrew year that starts on Thursday, is `regular' (Heshvan has 29
394
+ * days and Kislev has 30 days), and has Passover start on Saturday. */
395
+ // e.g. 5745
396
+ '0511': yearStartHaazinu.concat(r020, D(21), 23, 24, PESACH, 25, D(26), D(28), range(30, 40), D(41), r4350),
397
+ /* Hebrew year that starts on Thursday, is `complete' (Heshvan and
398
+ * Kislev each have 30 days), and has Passover start on Sunday. */
399
+ // e.g. 5754
400
+ '052': yearStartHaazinu.concat(range(0, 24), PESACH7, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
401
+ /* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and Kislev
402
+ * each have 29 days), and has Passover start on Sunday. */
403
+ // e.g. 5761
404
+ '070': yearStartRH.concat(r020, D(21), 23, 24, PESACH7, 25, D(26), D(28), 30, D(31), r3340, D(41), r4350),
405
+ /* Hebrew year that starts on Saturday, is `complete' (Heshvan and
406
+ * Kislev each have 30 days), and has Passover start on Tuesday. */
407
+ // e.g. 5716
408
+ '072': yearStartRH.concat(r020, D(21), 23, 24, CHMPESACH, 25, D(26), D(28), 30, D(31), r3340, D(41), r4349, D(50)),
409
+ /* -- The leap year types (keviot) -- */
410
+ /* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
411
+ * Kislev each have 29 days), and has Passover start on Thursday. */
412
+ // e.g. 5746
413
+ '1200': yearStartVayeilech.concat(r027, CHMPESACH, range(28, 33), SHAVUOT, range(34, 37), D(38), 40, D(41), r4349, D(50)),
414
+ /* Hebrew year that starts on Monday, is `incomplete' (Heshvan and
415
+ * Kislev each have 29 days), and has Passover start on Thursday. */
416
+ // e.g. 5746
417
+ '1201': yearStartVayeilech.concat(r027, CHMPESACH, range(28, 40), D(41), r4349, D(50)),
418
+ /* Hebrew year that starts on Monday, is `complete' (Heshvan and
419
+ * Kislev each have 30 days), and has Passover start on Saturday. */
420
+ // e.g.5752
421
+ '1220': yearStartVayeilech.concat(r027, PESACH1, PESACH8, range(28, 40), D(41), r4350),
422
+ /* Hebrew year that starts on Monday, is `complete' (Heshvan and
423
+ * Kislev each have 30 days), and has Passover start on Saturday. */
424
+ // e.g.5752
425
+ '1221': yearStartVayeilech.concat(r027, PESACH, range(28, 50)),
426
+ /* Hebrew year that starts on Thursday, is `incomplete' (Heshvan and
427
+ * Kislev both have 29 days), and has Passover start on Sunday. */
428
+ // e.g. 5768
429
+ '150': yearStartHaazinu.concat(range(0, 28), PESACH7, range(29, 50)),
430
+ /* Hebrew year that starts on Thursday, is `complete' (Heshvan and
431
+ * Kislev both have 30 days), and has Passover start on Tuesday. */
432
+ // eg. 5771
433
+ '152': yearStartHaazinu.concat(range(0, 28), CHMPESACH, range(29, 49), D(50)),
434
+ /* Hebrew year that starts on Saturday, is `incomplete' (Heshvan and
435
+ * Kislev each have 29 days), and has Passover start on Tuesday. */
436
+ // e.g.5757
437
+ '170': yearStartRH.concat(r027, CHMPESACH, range(28, 40), D(41), r4349, D(50)),
438
+ /* Hebrew year that starts on Saturday, is `complete' (Heshvan and
439
+ * Kislev each have 30 days), and has Passover start on Thursday. */
440
+ '1720': yearStartRH.concat(r027, CHMPESACH, range(28, 33), SHAVUOT, range(34, 37), D(38), 40, D(41), r4349, D(50)),
441
+ };
442
+ /* Hebrew year that starts on Monday, is `complete' (Heshvan and
443
+ * Kislev each have 30 days), and has Passover start on Thursday. */
444
+ types['0221'] = types['020'];
445
+ /* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
446
+ * days and Kislev has 30 days), and has Passover start on Thursday. */
447
+ // e.g. 5715
448
+ types['0310'] = types['0220'];
449
+ /* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
450
+ * days and Kislev has 30 days), and has Passover start on Thursday. */
451
+ types['0311'] = types['020'];
452
+ /* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
453
+ * days and Kislev has 30 days), and has Passover start on Saturday. */
454
+ // e.g. 5715
455
+ types['1310'] = types['1220'];
456
+ /* Hebrew year that starts on Tuesday, is `regular' (Heshvan has 29
457
+ * days and Kislev has 30 days), and has Passover start on Saturday. */
458
+ types['1311'] = types['1221'];
459
+ /* Hebrew year that starts on Saturday, is `complete' (Heshvan and
460
+ * Kislev each have 30 days), and has Passover start on Thursday. */
461
+ types['1721'] = types['170'];
462
+ const sedraCache = new QuickLRU({ maxSize: 400 });
463
+ /**
464
+ * Convenience function to create an instance of `Sedra` or reuse a previously
465
+ * created and cached instance.
466
+ * @param hyear
467
+ * @param il
468
+ */
469
+ export function getSedra(hyear, il) {
470
+ const cacheKey = `${hyear}-${il ? 1 : 0}`;
471
+ let sedra = sedraCache.get(cacheKey);
472
+ if (!sedra) {
473
+ sedra = new Sedra(hyear, il);
474
+ sedraCache.set(cacheKey, sedra);
475
+ }
476
+ return sedra;
477
+ }