@hebcal/leyning 5.0.0 → 6.0.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/leyning.d.ts CHANGED
@@ -20,6 +20,10 @@ declare module '@hebcal/leyning' {
20
20
  p?: number;
21
21
  };
22
22
 
23
+ export type StringMap = {
24
+ [key: string]: string;
25
+ }
26
+
23
27
  export type AliyotMap = {
24
28
  [key: string]: Aliyah;
25
29
  }
@@ -58,11 +62,52 @@ declare module '@hebcal/leyning' {
58
62
  /** Optional map of weekday Torah Readings aliyot `1` through `3` for Monday and Thursday */
59
63
  weekday?: AliyotMap;
60
64
  /** Explanations for special readings, keyed by aliyah number, `M` for maftir or `haftara` for Haftarah */
61
- reason?: {
62
- [key: string]: string;
63
- };
65
+ reason?: StringMap;
64
66
  };
65
67
 
68
+ /**
69
+ * Formats parsha as a string
70
+ */
71
+ export function parshaToString(parsha: string[]): string;
72
+ /**
73
+ * Makes a deep copy of the src object using JSON stringify and parse
74
+ */
75
+ export function clone(src: any): any;
76
+ /**
77
+ * Calculates the number of verses in an aliyah or haftara based on
78
+ * the `b` (begin verse), `e` (end verse) and `k` (book).
79
+ * Modifies `aliyah` by setting the `v` field.
80
+ */
81
+ export function calculateNumVerses(aliyah: Aliyah): number;
82
+ /**
83
+ * Returns the total number of verses in an array of Aliyah (or haftarah) objects
84
+ */
85
+ export function sumVerses(aliyot: Aliyah | Aliyah[]): number;
86
+ /**
87
+ * Summarizes an `AliyotMap` by collapsing all adjacent aliyot.
88
+ * Finds any non-overlapping parts (e.g. special 7th aliyah or maftir)
89
+ */
90
+ export function makeLeyningParts(aliyot: AliyotMap): Aliyah[];
91
+ /**
92
+ * Returns a string representation of the leyning parts.
93
+ * Separate verse ranges read from the same book are separated
94
+ * by commas, e.g. `Isaiah 6:1-7:6, 9:5-6`.
95
+ * Verse ranges from different books are separated by semicolons,
96
+ * e.g. `Genesis 21:1-34; Numbers 29:1-6`.
97
+ */
98
+ export function makeSummaryFromParts(parts: Aliyah | Aliyah[]): string;
99
+ /**
100
+ * Determines if the regular parashat haShavua coincides with an event that requires
101
+ * a special maftir or Haftara (for example Shabbat HaGadol, Shabbat Chanukah, Rosh
102
+ * Chodesh or Machar Chodesh, etc.).
103
+ *
104
+ * If a special maftir occurs, modifies `aliyot` to replace `M` and sets `reason.M`
105
+ * (and in some cases modifies the 6th and 7th aliyah, setting `reason['7']`).
106
+ *
107
+ * If a special Haftarah applies, returns the Haftarah object and sets `reason.haftara`.
108
+ * If no special Haftarah, returns `undefined`
109
+ */
110
+ export function specialReadings(hd: HDate, il: boolean, aliyot: AliyotMap, reason: StringMap): Aliyah | Aliyah[];
66
111
  /**
67
112
  * Looks up leyning for a regular Shabbat, Monday/Thursday weekday or holiday.
68
113
  *
@@ -139,63 +184,52 @@ declare module '@hebcal/leyning' {
139
184
  export function formatAliyahShort(aliyah: Aliyah, showBook: boolean): string;
140
185
 
141
186
  /**
142
- * Represents triennial aliyot for a given date
187
+ * Names of the books of the Torah. BOOK[1] === 'Genesis'
143
188
  */
144
- export type TriennialAliyot = {
145
- /** Map of aliyot `1` through `7` plus `M` for maftir */
146
- aliyot: AliyotMap;
147
- /** year number, 0-2 */
148
- yearNum: number;
149
- /** Shabbat date for when this parsha is read in this 3-year cycle */
150
- date: Date;
151
- /** true if a double parsha is read separately in year `yearNum` */
152
- readSeparately?: boolean;
153
- /** Shabbat date of the first part of a read-separately aliyah pair */
154
- date1?: Date;
155
- /** Shabbat date of the second part of a read-separately aliyah pair */
156
- date2?: Date;
157
- };
189
+ export const BOOK: string[];
158
190
 
191
+ export function writeFullKriyahCsv(stream: WriteStream, hyear: number, il: boolean): void;
159
192
  /**
160
- * Triennial Torah readings
161
- */
162
- export class Triennial {
163
- constructor(hebrewYear: number);
164
- getReading(parsha: string, yearNum: number): TriennialAliyot;
165
- getStartYear(): number;
166
- debug(): string;
167
- /**
168
- * Returns triennial year 1, 2 or 3 based on this Hebrew year
169
- * @param year Hebrew year
170
- */
171
- static getYearNumber(year: number): number;
172
- /**
173
- * Returns Hebrew year that this 3-year triennial cycle began
174
- * @param year Hebrew year
175
- */
176
- static getCycleStartYear(year: number): number;
177
- }
193
+ * Formats reading for CSV
194
+ */
195
+ export function writeCsvLines(stream: WriteStream, ev: Event, reading: Leyning, il: boolean, isParsha: boolean): void;
178
196
 
179
197
  /**
180
- * Calculates the 3-year readings for a given year
181
- * @param year - Hebrew year
198
+ * Parsha metadata (underlying JSON object)
182
199
  */
183
- export function getTriennial(year: number): Triennial;
200
+ export type ParshaMeta = {
201
+ /** 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings */
202
+ num: number;
203
+ /** parsha name in Hebrew with niqud */
204
+ hebrew: string;
205
+ /** 1 for Genesis, 2 for Exodus, 5 for Deuteronomy */
206
+ book: number;
207
+ /** Haftarah object(s) */
208
+ haft: Aliyah | Aliyah[];
209
+ /** Haftarah object(s) for Sephardim */
210
+ seph?: Aliyah | Aliyah[];
211
+ /** Raw map of Shabbat aliyot `1` through `7` plus `M` for maftir */
212
+ fullkriyah: {
213
+ [key: string]: string[];
214
+ };
215
+ /** weekday - raw map of weekday Torah Readings aliyot `1` through `3` for Mon & Thu */
216
+ weekday: {
217
+ [key: string]: string[];
218
+ };
219
+ };
184
220
 
185
221
  /**
186
- * Looks up triennial leyning for a regular Shabbat parsha.
187
- * @param ev - the Hebcal event associated with this parsha
188
- * @returns a map of aliyot 1-7 plus "M"
222
+ * Returns raw parsha metadata
189
223
  */
190
- export function getTriennialForParshaHaShavua(ev: Event): TriennialAliyot;
191
-
192
- export function getTriennialHaftaraForHoliday(holiday: string, yearNum: number): any;
224
+ export function lookupParsha(parsha: string | string[]): ParshaMeta;
193
225
 
194
226
  /**
195
- * Names of the books of the Torah. BOOK[1] === 'Genesis'
227
+ * Is there a special festival Torah Reading for `holiday`?
196
228
  */
197
- export const BOOK: string[];
198
-
199
- export function writeTriennialCsv(stream: WriteStream, hyear: number): void;
200
- export function writeFullKriyahCsv(stream: WriteStream, hyear: number, il: boolean): void;
229
+ export function hasFestival(holiday: string): boolean;
230
+
231
+ /**
232
+ * Returns the raw metadata for festival reading for `holiday`
233
+ */
234
+ export function lookupFestival(holiday: string): any;
201
235
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/leyning",
3
- "version": "5.0.0",
3
+ "version": "6.0.0",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "keywords": [
6
6
  "hebcal",
@@ -52,7 +52,7 @@
52
52
  "verbose": true
53
53
  },
54
54
  "devDependencies": {
55
- "@babel/core": "^7.18.10",
55
+ "@babel/core": "^7.18.13",
56
56
  "@babel/preset-env": "^7.18.10",
57
57
  "@babel/register": "^7.18.9",
58
58
  "@rollup/plugin-babel": "^5.3.1",