@hebcal/leyning 5.2.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
  *
@@ -138,66 +183,16 @@ declare module '@hebcal/leyning' {
138
183
  */
139
184
  export function formatAliyahShort(aliyah: Aliyah, showBook: boolean): string;
140
185
 
141
- /**
142
- * Represents triennial aliyot for a given date
143
- */
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
- };
158
-
159
- /**
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
- }
178
-
179
- /**
180
- * Calculates the 3-year readings for a given year
181
- * @param year - Hebrew year
182
- */
183
- export function getTriennial(year: number): Triennial;
184
-
185
- /**
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"
189
- */
190
- export function getTriennialForParshaHaShavua(ev: Event): TriennialAliyot;
191
-
192
- export function getTriennialHaftaraForHoliday(holiday: string, yearNum: number): any;
193
-
194
186
  /**
195
187
  * Names of the books of the Torah. BOOK[1] === 'Genesis'
196
188
  */
197
189
  export const BOOK: string[];
198
190
 
199
- export function writeTriennialCsv(stream: WriteStream, hyear: number): void;
200
191
  export function writeFullKriyahCsv(stream: WriteStream, hyear: number, il: boolean): void;
192
+ /**
193
+ * Formats reading for CSV
194
+ */
195
+ export function writeCsvLines(stream: WriteStream, ev: Event, reading: Leyning, il: boolean, isParsha: boolean): void;
201
196
 
202
197
  /**
203
198
  * Parsha metadata (underlying JSON object)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/leyning",
3
- "version": "5.2.0",
3
+ "version": "6.0.0",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "keywords": [
6
6
  "hebcal",