@hebcal/leyning 8.2.9 → 9.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.
Files changed (47) hide show
  1. package/dist/bundle.js +1660 -2155
  2. package/dist/bundle.min.js +2 -2
  3. package/dist/esm/aliyot.json.js +4 -0
  4. package/dist/esm/calculateHaftarahNumVerses.d.ts +1 -0
  5. package/dist/esm/clone.d.ts +12 -0
  6. package/dist/esm/clone.js +32 -0
  7. package/dist/esm/common.d.ts +33 -0
  8. package/dist/esm/common.js +94 -0
  9. package/dist/esm/csv.d.ts +14 -0
  10. package/dist/esm/festival.d.ts +9 -0
  11. package/dist/esm/festival.js +42 -0
  12. package/dist/esm/getLeyningForHoliday.d.ts +17 -0
  13. package/dist/esm/getLeyningForHoliday.js +106 -0
  14. package/dist/esm/getLeyningKeyForEvent.d.ts +9 -0
  15. package/dist/esm/getLeyningKeyForEvent.js +141 -0
  16. package/dist/esm/getLeyningOnDate.d.ts +21 -0
  17. package/dist/esm/getLeyningOnDate.js +134 -0
  18. package/dist/esm/he.po.d.ts +61 -0
  19. package/dist/esm/he.po.js +4 -0
  20. package/dist/esm/holiday-readings.json.js +4 -0
  21. package/dist/esm/index.d.ts +11 -0
  22. package/dist/esm/index.js +12 -0
  23. package/dist/esm/internalTypes.d.ts +20 -0
  24. package/dist/esm/leyning.d.ts +30 -0
  25. package/dist/esm/leyning.js +203 -0
  26. package/dist/esm/locale.d.ts +2 -0
  27. package/dist/esm/locale.js +17 -0
  28. package/dist/esm/numverses.json.js +4 -0
  29. package/dist/esm/specialReadings.d.ts +15 -0
  30. package/dist/esm/specialReadings.js +142 -0
  31. package/dist/esm/summary.d.ts +18 -0
  32. package/dist/esm/summary.js +83 -0
  33. package/dist/esm/types.d.ts +130 -0
  34. package/dist/getLeyningForHoliday.d.ts +1 -1
  35. package/dist/getLeyningKeyForEvent.d.ts +1 -1
  36. package/dist/getLeyningOnDate.d.ts +1 -1
  37. package/dist/index.cjs +47 -2147
  38. package/dist/index.d.ts +1 -2
  39. package/dist/leyning.d.ts +1 -1
  40. package/dist/locale.d.ts +2 -1
  41. package/dist/specialReadings.d.ts +1 -1
  42. package/package.json +21 -13
  43. package/dist/aliyot.json.d.ts +0 -1570
  44. package/dist/holiday-readings.json.d.ts +0 -2703
  45. package/dist/index.mjs +0 -3039
  46. package/dist/module.d.ts +0 -325
  47. package/dist/numverses.json.d.ts +0 -36
@@ -0,0 +1,83 @@
1
+ /*! @hebcal/leyning v9.0.0 */
2
+ import { formatAliyahShort } from './common.js';
3
+
4
+ /**
5
+ * @private
6
+ */
7
+ function isChapVerseBefore(a, b) {
8
+ const cv1 = a.split(':').map(x => +x);
9
+ const cv2 = b.split(':').map(x => +x);
10
+ return cv1[0] * 100 + cv1[1] < cv2[0] * 100 + cv2[1];
11
+ }
12
+ /**
13
+ * Summarizes an `AliyotMap` by collapsing all adjacent aliyot.
14
+ * Finds any non-overlapping parts (e.g. special 7th aliyah or maftir)
15
+ */
16
+ function makeLeyningParts(aliyot) {
17
+ const nums = Object.keys(aliyot).filter(x => {
18
+ if (x.length === 1) {
19
+ return true;
20
+ }
21
+ const code = x.charCodeAt(0);
22
+ return code >= 48 && code <= 57;
23
+ });
24
+ let start = aliyot[nums[0]];
25
+ let end = start;
26
+ const parts = [];
27
+ for (let i = 0; i < nums.length; i++) {
28
+ const num = nums[i];
29
+ const aliyah = aliyot[num];
30
+ if (i === nums.length - 1 && aliyah.k === end.k && aliyah.e === end.e) {
31
+ // short-circuit when final aliyah is within the previous (e.g. M inside of 7)
32
+ continue;
33
+ }
34
+ const prevEndChap = +end.e.split(':')[0];
35
+ const curStartChap = +aliyah.b.split(':')[0];
36
+ const sameOrNextChap = curStartChap === prevEndChap || curStartChap === prevEndChap + 1;
37
+ if (i !== 0 &&
38
+ (aliyah.k !== start.k ||
39
+ isChapVerseBefore(aliyah.b, start.e) ||
40
+ !sameOrNextChap)) {
41
+ parts.push({ k: start.k, b: start.b, e: end.e });
42
+ start = aliyah;
43
+ }
44
+ end = aliyah;
45
+ }
46
+ parts.push({ k: start.k, b: start.b, e: end.e });
47
+ return parts;
48
+ }
49
+ /**
50
+ * Returns a string representation of the leyning parts.
51
+ * Separate verse ranges read from the same book are separated
52
+ * by commas, e.g. `Isaiah 6:1-7:6, 9:5-6`.
53
+ * Verse ranges from different books are separated by semicolons,
54
+ * e.g. `Genesis 21:1-34; Numbers 29:1-6`.
55
+ */
56
+ function makeSummaryFromParts(parts) {
57
+ if (!Array.isArray(parts)) {
58
+ parts = [parts];
59
+ }
60
+ let prev = parts[0];
61
+ let summary = formatAliyahShort(prev, true);
62
+ for (let i = 1; i < parts.length; i++) {
63
+ const part = parts[i];
64
+ if (part.k === prev.k) {
65
+ summary += ', ';
66
+ }
67
+ else {
68
+ summary += `; ${part.k} `;
69
+ }
70
+ summary += formatAliyahShort(part, false);
71
+ prev = part;
72
+ }
73
+ return summary;
74
+ }
75
+ /**
76
+ * Makes a summary of the leyning, like "Genesis 6:9-11:32"
77
+ */
78
+ function makeLeyningSummary(aliyot) {
79
+ const parts = makeLeyningParts(aliyot);
80
+ return makeSummaryFromParts(parts);
81
+ }
82
+
83
+ export { makeLeyningParts, makeLeyningSummary, makeSummaryFromParts };
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Represents an aliyah
3
+ */
4
+ export type Aliyah = {
5
+ /** Book (e.g. "Numbers") */
6
+ k: string;
7
+ /** beginning verse (e.g. "28:9") */
8
+ b: string;
9
+ /** ending verse (e.g. "28:15") */
10
+ e: string;
11
+ /** number of verses */
12
+ v?: number;
13
+ /** parsha number (1=Bereshit, 54=Vezot HaBracha) */
14
+ p?: number;
15
+ reason?: string;
16
+ };
17
+ export type StringMap = {
18
+ [key: string]: string;
19
+ };
20
+ export type AliyotMap = {
21
+ [key: string]: Aliyah;
22
+ };
23
+ /** Name of the parsha hashavua or holiday */
24
+ export type LeyningNames = {
25
+ /** English */
26
+ en: string;
27
+ /** Hebrew (with nikud) */
28
+ he: string;
29
+ };
30
+ /**
31
+ * Parsha metadata (underlying JSON object)
32
+ */
33
+ export type ParshaMeta = {
34
+ /** 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings */
35
+ num: number | number[];
36
+ /** parsha name in Hebrew with niqud */
37
+ hebrew: string;
38
+ /** 1 for Genesis, 2 for Exodus, 5 for Deuteronomy */
39
+ book: number;
40
+ /** Haftarah object(s) */
41
+ haft: Aliyah | Aliyah[];
42
+ /** Haftarah object(s) for Sephardim */
43
+ seph?: Aliyah | Aliyah[];
44
+ /** Map of Shabbat aliyot `1` through `7` plus `M` for maftir */
45
+ fullkriyah: {
46
+ [key: string]: string[];
47
+ };
48
+ /**
49
+ * Map of weekday Torah Readings
50
+ * aliyot `1` through `3` for Monday and Thursday
51
+ */
52
+ weekday?: {
53
+ [key: string]: string[];
54
+ };
55
+ combined?: boolean;
56
+ p1?: string;
57
+ p2?: string;
58
+ num1?: number;
59
+ num2?: number;
60
+ };
61
+ export type SpecialReading = {
62
+ /** Map of aliyot `1` through `7` plus `M` for maftir */
63
+ aliyot: AliyotMap;
64
+ /**
65
+ * Explanations for special readings,
66
+ * keyed by aliyah number, `M` for maftir or `haftara` for Haftarah
67
+ */
68
+ reason: StringMap;
69
+ /** Haftarah object(s) */
70
+ haft?: Aliyah | Aliyah[];
71
+ /** Haftarah object(s) for Sephardim */
72
+ seph?: Aliyah | Aliyah[];
73
+ };
74
+ /**
75
+ * Leyning base - weekday, parsha hashavua or holiday
76
+ */
77
+ export type LeyningBase = {
78
+ /** Name of the parsha hashavua or holiday */
79
+ name: LeyningNames;
80
+ /** Such as `Genesis 1:1 - 6:8` */
81
+ summary: string;
82
+ summaryParts?: Aliyah[];
83
+ note?: string;
84
+ };
85
+ /**
86
+ * Parashat haShavua - weekday or Shabbat
87
+ */
88
+ export type LeyningParshaHaShavua = LeyningBase & {
89
+ /** An array of either 1 (regular) or 2 (doubled parsha). `undefined` for holiday readings */
90
+ parsha?: string[];
91
+ /** 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings */
92
+ parshaNum?: number | number[];
93
+ };
94
+ /**
95
+ * Parashat haShavua - weekday
96
+ */
97
+ export type LeyningWeekday = LeyningParshaHaShavua & {
98
+ /** Optional map of weekday Torah Readings aliyot `1` through `3` for Monday and Thursday */
99
+ weekday?: AliyotMap;
100
+ };
101
+ export type HaftarahProps = {
102
+ /** Haftarah object */
103
+ haft: Aliyah | Aliyah[];
104
+ /** Haftarah, such as `Isaiah 42:5 – 43:11` */
105
+ haftara: string;
106
+ /** Number of verses in the Haftarah */
107
+ haftaraNumV?: number;
108
+ };
109
+ /**
110
+ * Shabbat and holiday leyning always has full kriyah and haftarah
111
+ */
112
+ export type LeyningShabbatHoliday = LeyningBase & HaftarahProps & {
113
+ /** Map of aliyot `1` through `7` plus `M` for maftir */
114
+ fullkriyah: AliyotMap;
115
+ /** Haftarah object for Sephardim */
116
+ seph?: Aliyah | Aliyah[];
117
+ /** Haftarah for Sephardim, such as `Isaiah 42:5 - 42:21` */
118
+ sephardic?: string;
119
+ /** Number of verses in the Haftarah for Sephardim */
120
+ sephardicNumV?: number;
121
+ /** Explanations for special readings, keyed by aliyah number, `M` for maftir or `haftara` for Haftarah */
122
+ reason?: StringMap;
123
+ /** Song of Songs is read on the sabbath of Passover week, the Book of Ruth on Shavuot, Lamentations on Tisha be-Av, Ecclesiastes on the sabbath of the week of Sukkoth, and the Book of Esther on Purim */
124
+ megillah?: AliyotMap;
125
+ /** Triennial alternate Haftara */
126
+ triHaftara?: string;
127
+ /** Triennial alternate Haftara number of verses */
128
+ triHaftaraNumV?: number;
129
+ };
130
+ export type Leyning = LeyningBase & LeyningParshaHaShavua & LeyningShabbatHoliday & LeyningWeekday;
@@ -1,4 +1,4 @@
1
- import { Event } from '@hebcal/core';
1
+ import { Event } from '@hebcal/core/dist/esm/event';
2
2
  import { Leyning } from './types';
3
3
  /**
4
4
  * Looks up leyning for a given holiday key. Key should be an
@@ -1,4 +1,4 @@
1
- import { Event } from '@hebcal/core';
1
+ import { Event } from '@hebcal/core/dist/esm/event';
2
2
  export declare const HOLIDAY_IGNORE_MASK: number;
3
3
  /**
4
4
  * Based on the event date, type and title, finds the relevant leyning key
@@ -1,4 +1,4 @@
1
- import { HDate } from '@hebcal/core';
1
+ import { HDate } from '@hebcal/hdate';
2
2
  import { Leyning, LeyningWeekday } from './types';
3
3
  /**
4
4
  * Looks up leyning for a regular Shabbat, Monday/Thursday weekday or holiday.