@hebcal/leyning 8.0.0 → 8.1.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/README.md +15 -1
- package/dist/bundle.js +84 -74
- package/dist/bundle.min.js +2 -2
- package/dist/index.js +84 -74
- package/dist/index.mjs +84 -75
- package/leyning.d.ts +15 -6
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -108,6 +108,9 @@ of full kriyah aliyot, special Maftir, special Haftarah</p>
|
|
|
108
108
|
<dd><p>Looks up leyning for a given holiday. Returns some
|
|
109
109
|
of full kriyah aliyot, special Maftir, special Haftarah</p>
|
|
110
110
|
</dd>
|
|
111
|
+
<dt><a href="#makeLeyningNames">makeLeyningNames(parsha)</a> ⇒ <code><a href="#LeyningNames">LeyningNames</a></code></dt>
|
|
112
|
+
<dd><p>Transliterated English and Hebrew names of this parsha</p>
|
|
113
|
+
</dd>
|
|
111
114
|
<dt><a href="#getWeekdayReading">getWeekdayReading(parsha)</a> ⇒ <code>Object.<string, Aliyah></code></dt>
|
|
112
115
|
<dd><p>Looks up Monday/Thursday aliyot for a regular parsha</p>
|
|
113
116
|
</dd>
|
|
@@ -357,6 +360,17 @@ of full kriyah aliyot, special Maftir, special Haftarah
|
|
|
357
360
|
| ev | <code>Event</code> | | the Hebcal event associated with this leyning |
|
|
358
361
|
| [il] | <code>boolean</code> | <code>false</code> | true if Israel holiday scheme |
|
|
359
362
|
|
|
363
|
+
<a name="makeLeyningNames"></a>
|
|
364
|
+
|
|
365
|
+
## makeLeyningNames(parsha) ⇒ [<code>LeyningNames</code>](#LeyningNames)
|
|
366
|
+
Transliterated English and Hebrew names of this parsha
|
|
367
|
+
|
|
368
|
+
**Kind**: global function
|
|
369
|
+
|
|
370
|
+
| Param | Type | Description |
|
|
371
|
+
| --- | --- | --- |
|
|
372
|
+
| parsha | <code>string</code> \| <code>Array.<string></code> | untranslated name like 'Pinchas' or ['Pinchas'] or ['Matot','Masei'] |
|
|
373
|
+
|
|
360
374
|
<a name="getWeekdayReading"></a>
|
|
361
375
|
|
|
362
376
|
## getWeekdayReading(parsha) ⇒ <code>Object.<string, Aliyah></code>
|
|
@@ -501,7 +515,7 @@ Leyning for a parsha hashavua or holiday
|
|
|
501
515
|
| --- | --- | --- |
|
|
502
516
|
| name | [<code>LeyningNames</code>](#LeyningNames) | |
|
|
503
517
|
| [parsha] | <code>Array.<string></code> | An array of either 1 (regular) or 2 (doubled parsha). `undefined` for holiday readings |
|
|
504
|
-
| [parshaNum] | <code>number</code> | 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings |
|
|
518
|
+
| [parshaNum] | <code>number</code> \| <code>Array.<number></code> | 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings |
|
|
505
519
|
| summary | <code>string</code> | Such as `Genesis 1:1 - 6:8` |
|
|
506
520
|
| haft | [<code>Aliyah</code>](#Aliyah) \| [<code>Array.<Aliyah></code>](#Aliyah) | Haftarah object(s) |
|
|
507
521
|
| haftara | <code>string</code> | Haftarah, such as `Isaiah 42:5 – 43:11` |
|
package/dist/bundle.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/leyning v8.
|
|
1
|
+
/*! @hebcal/leyning v8.1.0 */
|
|
2
2
|
var hebcal__leyning = (function (exports, core) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -262,11 +262,11 @@ function lookupFestival(holiday) {
|
|
|
262
262
|
}
|
|
263
263
|
const result = src.fullkriyah ? clone(src) : src;
|
|
264
264
|
if (result.fullkriyah) {
|
|
265
|
-
Object.values(result.fullkriyah)
|
|
265
|
+
for (const aliyah of Object.values(result.fullkriyah)) {
|
|
266
266
|
if (typeof aliyah.k === 'number') {
|
|
267
267
|
aliyah.k = BOOK[aliyah.k];
|
|
268
268
|
}
|
|
269
|
-
}
|
|
269
|
+
}
|
|
270
270
|
}
|
|
271
271
|
if (src.note) {
|
|
272
272
|
result.note = src.note;
|
|
@@ -310,32 +310,23 @@ function getLeyningKeyForEvent(ev) {
|
|
|
310
310
|
}
|
|
311
311
|
return desc;
|
|
312
312
|
}
|
|
313
|
+
const cholHaMoedDay = ev.cholHaMoedDay;
|
|
313
314
|
if (day == 1 && month === core.months.TISHREI) {
|
|
314
315
|
return isShabbat ? 'Rosh Hashana I (on Shabbat)' : 'Rosh Hashana I';
|
|
315
|
-
} else if (
|
|
316
|
+
} else if (cholHaMoedDay) {
|
|
316
317
|
// Sukkot or Pesach
|
|
317
318
|
if (isShabbat) {
|
|
318
319
|
return holiday + ' Shabbat Chol ha-Moed';
|
|
319
320
|
} else if (desc == 'Sukkot VII (Hoshana Raba)') {
|
|
320
321
|
return 'Sukkot Final Day (Hoshana Raba)';
|
|
321
322
|
}
|
|
322
|
-
if (isPesach &&
|
|
323
|
+
if (isPesach && cholHaMoedDay) {
|
|
323
324
|
if (dow === 0 && desc === 'Pesach IV (CH\'\'M)') {
|
|
324
325
|
return 'Pesach Chol ha-Moed Day 2 on Sunday';
|
|
325
326
|
} else if (dow === 1 && desc === 'Pesach V (CH\'\'M)') {
|
|
326
327
|
return 'Pesach Chol ha-Moed Day 3 on Monday';
|
|
327
328
|
}
|
|
328
329
|
}
|
|
329
|
-
// If Shabbat falls on the third day of Chol ha-Moed Pesach,
|
|
330
|
-
// the readings for the third, fourth, and fifth days are moved ahead
|
|
331
|
-
let cholHaMoedDay = ev.cholHaMoedDay;
|
|
332
|
-
if (isPesach && cholHaMoedDay >= 3) {
|
|
333
|
-
if (dow == 0 && cholHaMoedDay == 4) {
|
|
334
|
-
cholHaMoedDay = 3;
|
|
335
|
-
} else if (dow == 1 && cholHaMoedDay == 5) {
|
|
336
|
-
cholHaMoedDay = 4;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
330
|
return `${holiday} Chol ha-Moed Day ${cholHaMoedDay}`;
|
|
340
331
|
} else if (ev.chanukahDay) {
|
|
341
332
|
if (isShabbat && isRoshChodesh) {
|
|
@@ -391,7 +382,6 @@ function getLeyningKeyForEvent(ev) {
|
|
|
391
382
|
return 'Chanukah Day 7 (on Rosh Chodesh)'; // 1st of Tevet
|
|
392
383
|
}
|
|
393
384
|
}
|
|
394
|
-
|
|
395
385
|
if (isRoshChodesh) {
|
|
396
386
|
return desc;
|
|
397
387
|
}
|
|
@@ -493,14 +483,16 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
493
483
|
if (special.fullkriyah) {
|
|
494
484
|
const aliyotMap = clone(aliyot);
|
|
495
485
|
mergeAliyotWithSpecial(aliyotMap, special.fullkriyah);
|
|
496
|
-
Object.keys(special.fullkriyah)
|
|
486
|
+
for (const num of Object.keys(special.fullkriyah)) {
|
|
487
|
+
reason[num] = key;
|
|
488
|
+
}
|
|
497
489
|
aliyot = aliyotMap;
|
|
498
490
|
}
|
|
499
491
|
}
|
|
500
492
|
const parshaName = parshaToString(parsha);
|
|
501
493
|
const events0 = core.HebrewCalendar.getHolidaysOnDate(hd, il) || [];
|
|
502
494
|
const events = events0.filter(ev => !(ev.getFlags() & core.flags.ROSH_CHODESH));
|
|
503
|
-
|
|
495
|
+
for (const ev of events) {
|
|
504
496
|
if (ev.getDesc() === 'Shabbat Shuva') {
|
|
505
497
|
handleSpecial(`Shabbat Shuva (with ${parshaName})`);
|
|
506
498
|
} else {
|
|
@@ -509,7 +501,7 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
509
501
|
handleSpecial(key);
|
|
510
502
|
}
|
|
511
503
|
}
|
|
512
|
-
}
|
|
504
|
+
}
|
|
513
505
|
if (!haft) {
|
|
514
506
|
const day = hd.getDate();
|
|
515
507
|
if (parshaName === 'Pinchas' && day > 17) {
|
|
@@ -668,7 +660,7 @@ const Bereshit={num:1,hebrew:"בְּרֵאשִׁית",book:1,haft:{k:"Isaiah",b:
|
|
|
668
660
|
* @property {LeyningNames} name
|
|
669
661
|
* @property {string[]} [parsha] - An array of either 1 (regular) or 2 (doubled parsha).
|
|
670
662
|
* `undefined` for holiday readings
|
|
671
|
-
* @property {number} [parshaNum] - 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings
|
|
663
|
+
* @property {number|number[]} [parshaNum] - 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings
|
|
672
664
|
* @property {string} summary - Such as `Genesis 1:1 - 6:8`
|
|
673
665
|
* @property {Aliyah|Aliyah[]} haft - Haftarah object(s)
|
|
674
666
|
* @property {string} haftara - Haftarah, such as `Isaiah 42:5 – 43:11`
|
|
@@ -702,6 +694,19 @@ function getHaftaraKey(parsha) {
|
|
|
702
694
|
}
|
|
703
695
|
}
|
|
704
696
|
|
|
697
|
+
/**
|
|
698
|
+
* Transliterated English and Hebrew names of this parsha
|
|
699
|
+
* @param {string|string[]} parsha untranslated name like 'Pinchas' or ['Pinchas'] or ['Matot','Masei']
|
|
700
|
+
* @return {LeyningNames}
|
|
701
|
+
*/
|
|
702
|
+
function makeLeyningNames(parsha) {
|
|
703
|
+
const name = parshaToString(parsha);
|
|
704
|
+
return {
|
|
705
|
+
en: name,
|
|
706
|
+
he: parsha.map(s => core.Locale.lookupTranslation(s, 'he')).join('־')
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
|
|
705
710
|
/**
|
|
706
711
|
* Looks up regular leyning for a weekly parsha with no special readings
|
|
707
712
|
* @private
|
|
@@ -712,26 +717,22 @@ function getLeyningForParshaShabbatOnly(parsha) {
|
|
|
712
717
|
const raw = lookupParsha(parsha);
|
|
713
718
|
const fullkriyah = {};
|
|
714
719
|
const book = BOOK[raw.book];
|
|
715
|
-
Object.
|
|
716
|
-
const
|
|
717
|
-
const reading = {
|
|
720
|
+
for (const [num, src] of Object.entries(raw.fullkriyah)) {
|
|
721
|
+
const aliyah = {
|
|
718
722
|
k: book,
|
|
719
723
|
b: src[0],
|
|
720
724
|
e: src[1]
|
|
721
725
|
};
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
726
|
+
calculateNumVerses(aliyah);
|
|
727
|
+
fullkriyah[num] = aliyah;
|
|
728
|
+
}
|
|
725
729
|
const name = parshaToString(parsha);
|
|
726
730
|
const parshaNameArray = raw.combined ? [raw.p1, raw.p2] : [name];
|
|
727
731
|
const parts = makeLeyningParts(fullkriyah);
|
|
728
732
|
const summary = makeSummaryFromParts(parts);
|
|
729
733
|
/** @type {Leyning} */
|
|
730
734
|
const result = {
|
|
731
|
-
name:
|
|
732
|
-
en: name,
|
|
733
|
-
he: parshaNameArray.map(s => core.Locale.lookupTranslation(s, 'he')).join('־')
|
|
734
|
-
},
|
|
735
|
+
name: makeLeyningNames(parshaNameArray),
|
|
735
736
|
parsha: parshaNameArray,
|
|
736
737
|
parshaNum: raw.num,
|
|
737
738
|
summary,
|
|
@@ -834,18 +835,20 @@ function getLeyningForParshaHaShavua(ev) {
|
|
|
834
835
|
const reasons = Object.keys(reason);
|
|
835
836
|
if (reasons.length !== 0) {
|
|
836
837
|
result.reason = reason;
|
|
837
|
-
|
|
838
|
+
for (const num of reasons) {
|
|
838
839
|
if (num === 'haftara' || num === 'sephardic') {
|
|
839
840
|
const haftObj = result[num === 'haftara' ? 'haft' : 'seph'];
|
|
840
841
|
const hafts = Array.isArray(haftObj) ? haftObj : [haftObj];
|
|
841
|
-
|
|
842
|
+
for (const haft of hafts) {
|
|
843
|
+
haft.reason = reason[num];
|
|
844
|
+
}
|
|
842
845
|
} else {
|
|
843
846
|
const aliyah = result.fullkriyah[num];
|
|
844
847
|
if (typeof aliyah === 'object') {
|
|
845
848
|
aliyah.reason = reason[num];
|
|
846
849
|
}
|
|
847
850
|
}
|
|
848
|
-
}
|
|
851
|
+
}
|
|
849
852
|
}
|
|
850
853
|
return result;
|
|
851
854
|
}
|
|
@@ -890,6 +893,18 @@ function findParshaHaShavua(saturday, il) {
|
|
|
890
893
|
if (!parsha.chag) {
|
|
891
894
|
return parsha;
|
|
892
895
|
}
|
|
896
|
+
// Special case between YK and Simchat Torah
|
|
897
|
+
if (saturday.getMonth() === core.months.TISHREI) {
|
|
898
|
+
const dd = saturday.getDate();
|
|
899
|
+
const simchatTorah = il ? 22 : 23;
|
|
900
|
+
if (dd > 10 && dd <= simchatTorah) {
|
|
901
|
+
return {
|
|
902
|
+
parsha: ['Vezot Haberakhah'],
|
|
903
|
+
chag: false,
|
|
904
|
+
num: 54
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
}
|
|
893
908
|
// Search for next regular parsha, which could even spill into next year
|
|
894
909
|
const endOfYear = new core.HDate(1, core.months.TISHREI, hyear + 1).abs() - 1;
|
|
895
910
|
const endAbs = endOfYear + 30;
|
|
@@ -925,48 +940,44 @@ function findParshaHaShavua(saturday, il) {
|
|
|
925
940
|
function getLeyningOnDate(hdate, il) {
|
|
926
941
|
let wantarray = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
927
942
|
const dow = hdate.getDay();
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
943
|
+
if (dow === 6) {
|
|
944
|
+
const hyear = hdate.getFullYear();
|
|
945
|
+
const sedra = core.HebrewCalendar.getSedra(hyear, il);
|
|
946
|
+
const parsha = sedra.lookup(hdate);
|
|
947
|
+
if (!parsha.chag) {
|
|
948
|
+
const parshaEvent = new core.ParshaEvent(hdate, parsha.parsha, il);
|
|
949
|
+
const reading = getLeyningForParshaHaShavua(parshaEvent, il);
|
|
950
|
+
return wantarray ? [reading] : reading;
|
|
951
|
+
}
|
|
935
952
|
}
|
|
936
953
|
const events = core.HebrewCalendar.getHolidaysOnDate(hdate, il) || [];
|
|
937
954
|
const arr = [];
|
|
938
|
-
|
|
939
|
-
|
|
955
|
+
let hasFullKriyah = false;
|
|
956
|
+
for (const ev of events) {
|
|
940
957
|
const reading = getLeyningForHoliday(ev, il);
|
|
941
958
|
if (reading) {
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
return reading;
|
|
959
|
+
arr.push(reading);
|
|
960
|
+
if (reading.fullkriyah) {
|
|
961
|
+
hasFullKriyah = true;
|
|
962
|
+
}
|
|
963
|
+
const mincha = getMincha(ev, il);
|
|
964
|
+
if (mincha) {
|
|
965
|
+
arr.push(mincha);
|
|
950
966
|
}
|
|
951
967
|
}
|
|
952
968
|
}
|
|
953
|
-
if (
|
|
954
|
-
return arr;
|
|
955
|
-
}
|
|
956
|
-
if (dow === 1 || dow === 4) {
|
|
969
|
+
if (!hasFullKriyah && (dow === 1 || dow === 4)) {
|
|
957
970
|
const saturday = hdate.onOrAfter(6);
|
|
958
|
-
const
|
|
959
|
-
const reading =
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
weekday: reading.weekday
|
|
971
|
+
const parsha = findParshaHaShavua(saturday);
|
|
972
|
+
const reading = {
|
|
973
|
+
name: makeLeyningNames(parsha.parsha),
|
|
974
|
+
parsha: parsha.parsha,
|
|
975
|
+
parshaNum: parsha.num,
|
|
976
|
+
weekday: getWeekdayReading(parsha.parsha)
|
|
965
977
|
};
|
|
966
|
-
|
|
978
|
+
arr.unshift(reading);
|
|
967
979
|
}
|
|
968
|
-
|
|
969
|
-
return wantarray ? [] : undefined;
|
|
980
|
+
return wantarray ? arr : arr[0];
|
|
970
981
|
}
|
|
971
982
|
const minchaSuffix = ' (Mincha)';
|
|
972
983
|
|
|
@@ -1038,11 +1049,11 @@ function writeFullKriyahCsv(stream, hyear, il) {
|
|
|
1038
1049
|
const events = events0.filter(ev => ev.getDesc() !== 'Rosh Chodesh Tevet');
|
|
1039
1050
|
const parshaDates = getParshaDates(events);
|
|
1040
1051
|
stream.write('"Date","Parashah","Aliyah","Reading","Verses"\r\n');
|
|
1041
|
-
|
|
1052
|
+
for (const ev of events) {
|
|
1042
1053
|
if (ev.getFlags() === core.flags.PARSHA_HASHAVUA || !parshaDates[ev.getDate().toString()]) {
|
|
1043
1054
|
writeFullKriyahEvent(stream, ev, il);
|
|
1044
1055
|
}
|
|
1045
|
-
}
|
|
1056
|
+
}
|
|
1046
1057
|
}
|
|
1047
1058
|
|
|
1048
1059
|
/**
|
|
@@ -1111,13 +1122,13 @@ function writeCsvLines(stream, ev, reading, il, isParsha) {
|
|
|
1111
1122
|
const parsha = isParsha ? ev.basename() : getLeyningKeyForEvent(ev, il) || ev.render();
|
|
1112
1123
|
const date = fmtDate(ev.getDate().greg());
|
|
1113
1124
|
const lines = getFullKriyahLines(reading);
|
|
1114
|
-
|
|
1125
|
+
for (const s of lines) {
|
|
1115
1126
|
const code = s[0].charCodeAt(0);
|
|
1116
1127
|
if (code < 48 || code > 57) {
|
|
1117
1128
|
s[0] = `"${s[0]}"`;
|
|
1118
1129
|
}
|
|
1119
1130
|
stream.write(`${date},"${parsha}",${s[0]},"${s[1]}",${s[2]}\r\n`);
|
|
1120
|
-
}
|
|
1131
|
+
}
|
|
1121
1132
|
stream.write('\r\n');
|
|
1122
1133
|
}
|
|
1123
1134
|
|
|
@@ -1129,8 +1140,7 @@ function writeCsvLines(stream, ev, reading, il, isParsha) {
|
|
|
1129
1140
|
function getFullKriyahLines(reading) {
|
|
1130
1141
|
const lines = [];
|
|
1131
1142
|
if (reading.fullkriyah) {
|
|
1132
|
-
Object.
|
|
1133
|
-
const a = reading.fullkriyah[num];
|
|
1143
|
+
for (const [num, a] of Object.entries(reading.fullkriyah)) {
|
|
1134
1144
|
if (typeof a !== 'undefined') {
|
|
1135
1145
|
var _reading$reason;
|
|
1136
1146
|
const k = num == 'M' ? 'maf' : num;
|
|
@@ -1140,7 +1150,7 @@ function getFullKriyahLines(reading) {
|
|
|
1140
1150
|
}
|
|
1141
1151
|
lines.push([k, aliyah, a.v || '']);
|
|
1142
1152
|
}
|
|
1143
|
-
}
|
|
1153
|
+
}
|
|
1144
1154
|
}
|
|
1145
1155
|
let specialHaftara = false;
|
|
1146
1156
|
if (reading.haftara) {
|
|
@@ -1161,13 +1171,12 @@ function getFullKriyahLines(reading) {
|
|
|
1161
1171
|
lines.push(['Alternate Haftara', haftara, reading.triHaftaraNumV || '']);
|
|
1162
1172
|
}
|
|
1163
1173
|
if (reading.megillah) {
|
|
1164
|
-
Object.
|
|
1165
|
-
const a = reading.megillah[num];
|
|
1174
|
+
for (const [num, a] of Object.entries(reading.megillah)) {
|
|
1166
1175
|
if (typeof a !== 'undefined') {
|
|
1167
1176
|
const aliyah = formatAliyahWithBook(a);
|
|
1168
1177
|
lines.push([`Megillah Ch. ${num}`, aliyah, a.v || '']);
|
|
1169
1178
|
}
|
|
1170
|
-
}
|
|
1179
|
+
}
|
|
1171
1180
|
}
|
|
1172
1181
|
return lines;
|
|
1173
1182
|
}
|
|
@@ -1189,6 +1198,7 @@ exports.getWeekdayReading = getWeekdayReading;
|
|
|
1189
1198
|
exports.hasFestival = hasFestival;
|
|
1190
1199
|
exports.lookupFestival = lookupFestival;
|
|
1191
1200
|
exports.lookupParsha = lookupParsha;
|
|
1201
|
+
exports.makeLeyningNames = makeLeyningNames;
|
|
1192
1202
|
exports.makeLeyningParts = makeLeyningParts;
|
|
1193
1203
|
exports.makeLeyningSummary = makeLeyningSummary;
|
|
1194
1204
|
exports.makeSummaryFromParts = makeSummaryFromParts;
|