@hebcal/leyning 8.0.1 → 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 +69 -61
- package/dist/bundle.min.js +2 -2
- package/dist/index.js +69 -61
- package/dist/index.mjs +69 -62
- package/leyning.d.ts +15 -6
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/leyning v8.0
|
|
1
|
+
/*! @hebcal/leyning v8.1.0 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var core = require('@hebcal/core');
|
|
@@ -263,11 +263,11 @@ function lookupFestival(holiday) {
|
|
|
263
263
|
}
|
|
264
264
|
const result = src.fullkriyah ? clone(src) : src;
|
|
265
265
|
if (result.fullkriyah) {
|
|
266
|
-
Object.values(result.fullkriyah)
|
|
266
|
+
for (const aliyah of Object.values(result.fullkriyah)) {
|
|
267
267
|
if (typeof aliyah.k === 'number') {
|
|
268
268
|
aliyah.k = BOOK[aliyah.k];
|
|
269
269
|
}
|
|
270
|
-
}
|
|
270
|
+
}
|
|
271
271
|
}
|
|
272
272
|
if (src.note) {
|
|
273
273
|
result.note = src.note;
|
|
@@ -483,14 +483,16 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
483
483
|
if (special.fullkriyah) {
|
|
484
484
|
const aliyotMap = clone(aliyot);
|
|
485
485
|
mergeAliyotWithSpecial(aliyotMap, special.fullkriyah);
|
|
486
|
-
Object.keys(special.fullkriyah)
|
|
486
|
+
for (const num of Object.keys(special.fullkriyah)) {
|
|
487
|
+
reason[num] = key;
|
|
488
|
+
}
|
|
487
489
|
aliyot = aliyotMap;
|
|
488
490
|
}
|
|
489
491
|
}
|
|
490
492
|
const parshaName = parshaToString(parsha);
|
|
491
493
|
const events0 = core.HebrewCalendar.getHolidaysOnDate(hd, il) || [];
|
|
492
494
|
const events = events0.filter(ev => !(ev.getFlags() & core.flags.ROSH_CHODESH));
|
|
493
|
-
|
|
495
|
+
for (const ev of events) {
|
|
494
496
|
if (ev.getDesc() === 'Shabbat Shuva') {
|
|
495
497
|
handleSpecial(`Shabbat Shuva (with ${parshaName})`);
|
|
496
498
|
} else {
|
|
@@ -499,7 +501,7 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
499
501
|
handleSpecial(key);
|
|
500
502
|
}
|
|
501
503
|
}
|
|
502
|
-
}
|
|
504
|
+
}
|
|
503
505
|
if (!haft) {
|
|
504
506
|
const day = hd.getDate();
|
|
505
507
|
if (parshaName === 'Pinchas' && day > 17) {
|
|
@@ -657,7 +659,7 @@ const Bereshit={num:1,hebrew:"בְּרֵאשִׁית",book:1,haft:{k:"Isaiah",b:
|
|
|
657
659
|
* @property {LeyningNames} name
|
|
658
660
|
* @property {string[]} [parsha] - An array of either 1 (regular) or 2 (doubled parsha).
|
|
659
661
|
* `undefined` for holiday readings
|
|
660
|
-
* @property {number} [parshaNum] - 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings
|
|
662
|
+
* @property {number|number[]} [parshaNum] - 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings
|
|
661
663
|
* @property {string} summary - Such as `Genesis 1:1 - 6:8`
|
|
662
664
|
* @property {Aliyah|Aliyah[]} haft - Haftarah object(s)
|
|
663
665
|
* @property {string} haftara - Haftarah, such as `Isaiah 42:5 – 43:11`
|
|
@@ -691,6 +693,19 @@ function getHaftaraKey(parsha) {
|
|
|
691
693
|
}
|
|
692
694
|
}
|
|
693
695
|
|
|
696
|
+
/**
|
|
697
|
+
* Transliterated English and Hebrew names of this parsha
|
|
698
|
+
* @param {string|string[]} parsha untranslated name like 'Pinchas' or ['Pinchas'] or ['Matot','Masei']
|
|
699
|
+
* @return {LeyningNames}
|
|
700
|
+
*/
|
|
701
|
+
function makeLeyningNames(parsha) {
|
|
702
|
+
const name = parshaToString(parsha);
|
|
703
|
+
return {
|
|
704
|
+
en: name,
|
|
705
|
+
he: parsha.map(s => core.Locale.lookupTranslation(s, 'he')).join('־')
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
|
|
694
709
|
/**
|
|
695
710
|
* Looks up regular leyning for a weekly parsha with no special readings
|
|
696
711
|
* @private
|
|
@@ -701,26 +716,22 @@ function getLeyningForParshaShabbatOnly(parsha) {
|
|
|
701
716
|
const raw = lookupParsha(parsha);
|
|
702
717
|
const fullkriyah = {};
|
|
703
718
|
const book = BOOK[raw.book];
|
|
704
|
-
Object.
|
|
705
|
-
const
|
|
706
|
-
const reading = {
|
|
719
|
+
for (const [num, src] of Object.entries(raw.fullkriyah)) {
|
|
720
|
+
const aliyah = {
|
|
707
721
|
k: book,
|
|
708
722
|
b: src[0],
|
|
709
723
|
e: src[1]
|
|
710
724
|
};
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
725
|
+
calculateNumVerses(aliyah);
|
|
726
|
+
fullkriyah[num] = aliyah;
|
|
727
|
+
}
|
|
714
728
|
const name = parshaToString(parsha);
|
|
715
729
|
const parshaNameArray = raw.combined ? [raw.p1, raw.p2] : [name];
|
|
716
730
|
const parts = makeLeyningParts(fullkriyah);
|
|
717
731
|
const summary = makeSummaryFromParts(parts);
|
|
718
732
|
/** @type {Leyning} */
|
|
719
733
|
const result = {
|
|
720
|
-
name:
|
|
721
|
-
en: name,
|
|
722
|
-
he: parshaNameArray.map(s => core.Locale.lookupTranslation(s, 'he')).join('־')
|
|
723
|
-
},
|
|
734
|
+
name: makeLeyningNames(parshaNameArray),
|
|
724
735
|
parsha: parshaNameArray,
|
|
725
736
|
parshaNum: raw.num,
|
|
726
737
|
summary,
|
|
@@ -822,18 +833,20 @@ function getLeyningForParshaHaShavua(ev, il = false) {
|
|
|
822
833
|
const reasons = Object.keys(reason);
|
|
823
834
|
if (reasons.length !== 0) {
|
|
824
835
|
result.reason = reason;
|
|
825
|
-
|
|
836
|
+
for (const num of reasons) {
|
|
826
837
|
if (num === 'haftara' || num === 'sephardic') {
|
|
827
838
|
const haftObj = result[num === 'haftara' ? 'haft' : 'seph'];
|
|
828
839
|
const hafts = Array.isArray(haftObj) ? haftObj : [haftObj];
|
|
829
|
-
|
|
840
|
+
for (const haft of hafts) {
|
|
841
|
+
haft.reason = reason[num];
|
|
842
|
+
}
|
|
830
843
|
} else {
|
|
831
844
|
const aliyah = result.fullkriyah[num];
|
|
832
845
|
if (typeof aliyah === 'object') {
|
|
833
846
|
aliyah.reason = reason[num];
|
|
834
847
|
}
|
|
835
848
|
}
|
|
836
|
-
}
|
|
849
|
+
}
|
|
837
850
|
}
|
|
838
851
|
return result;
|
|
839
852
|
}
|
|
@@ -924,48 +937,44 @@ function findParshaHaShavua(saturday, il) {
|
|
|
924
937
|
*/
|
|
925
938
|
function getLeyningOnDate(hdate, il, wantarray = false) {
|
|
926
939
|
const dow = hdate.getDay();
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
940
|
+
if (dow === 6) {
|
|
941
|
+
const hyear = hdate.getFullYear();
|
|
942
|
+
const sedra = core.HebrewCalendar.getSedra(hyear, il);
|
|
943
|
+
const parsha = sedra.lookup(hdate);
|
|
944
|
+
if (!parsha.chag) {
|
|
945
|
+
const parshaEvent = new core.ParshaEvent(hdate, parsha.parsha, il);
|
|
946
|
+
const reading = getLeyningForParshaHaShavua(parshaEvent, il);
|
|
947
|
+
return wantarray ? [reading] : reading;
|
|
948
|
+
}
|
|
934
949
|
}
|
|
935
950
|
const events = core.HebrewCalendar.getHolidaysOnDate(hdate, il) || [];
|
|
936
951
|
const arr = [];
|
|
937
|
-
|
|
938
|
-
|
|
952
|
+
let hasFullKriyah = false;
|
|
953
|
+
for (const ev of events) {
|
|
939
954
|
const reading = getLeyningForHoliday(ev, il);
|
|
940
955
|
if (reading) {
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
return reading;
|
|
956
|
+
arr.push(reading);
|
|
957
|
+
if (reading.fullkriyah) {
|
|
958
|
+
hasFullKriyah = true;
|
|
959
|
+
}
|
|
960
|
+
const mincha = getMincha(ev, il);
|
|
961
|
+
if (mincha) {
|
|
962
|
+
arr.push(mincha);
|
|
949
963
|
}
|
|
950
964
|
}
|
|
951
965
|
}
|
|
952
|
-
if (
|
|
953
|
-
return arr;
|
|
954
|
-
}
|
|
955
|
-
if (dow === 1 || dow === 4) {
|
|
966
|
+
if (!hasFullKriyah && (dow === 1 || dow === 4)) {
|
|
956
967
|
const saturday = hdate.onOrAfter(6);
|
|
957
|
-
const
|
|
958
|
-
const reading =
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
weekday: reading.weekday
|
|
968
|
+
const parsha = findParshaHaShavua(saturday);
|
|
969
|
+
const reading = {
|
|
970
|
+
name: makeLeyningNames(parsha.parsha),
|
|
971
|
+
parsha: parsha.parsha,
|
|
972
|
+
parshaNum: parsha.num,
|
|
973
|
+
weekday: getWeekdayReading(parsha.parsha)
|
|
964
974
|
};
|
|
965
|
-
|
|
975
|
+
arr.unshift(reading);
|
|
966
976
|
}
|
|
967
|
-
|
|
968
|
-
return wantarray ? [] : undefined;
|
|
977
|
+
return wantarray ? arr : arr[0];
|
|
969
978
|
}
|
|
970
979
|
const minchaSuffix = ' (Mincha)';
|
|
971
980
|
|
|
@@ -1037,11 +1046,11 @@ function writeFullKriyahCsv(stream, hyear, il) {
|
|
|
1037
1046
|
const events = events0.filter(ev => ev.getDesc() !== 'Rosh Chodesh Tevet');
|
|
1038
1047
|
const parshaDates = getParshaDates(events);
|
|
1039
1048
|
stream.write('"Date","Parashah","Aliyah","Reading","Verses"\r\n');
|
|
1040
|
-
|
|
1049
|
+
for (const ev of events) {
|
|
1041
1050
|
if (ev.getFlags() === core.flags.PARSHA_HASHAVUA || !parshaDates[ev.getDate().toString()]) {
|
|
1042
1051
|
writeFullKriyahEvent(stream, ev, il);
|
|
1043
1052
|
}
|
|
1044
|
-
}
|
|
1053
|
+
}
|
|
1045
1054
|
}
|
|
1046
1055
|
|
|
1047
1056
|
/**
|
|
@@ -1110,13 +1119,13 @@ function writeCsvLines(stream, ev, reading, il, isParsha) {
|
|
|
1110
1119
|
const parsha = isParsha ? ev.basename() : getLeyningKeyForEvent(ev, il) || ev.render();
|
|
1111
1120
|
const date = fmtDate(ev.getDate().greg());
|
|
1112
1121
|
const lines = getFullKriyahLines(reading);
|
|
1113
|
-
|
|
1122
|
+
for (const s of lines) {
|
|
1114
1123
|
const code = s[0].charCodeAt(0);
|
|
1115
1124
|
if (code < 48 || code > 57) {
|
|
1116
1125
|
s[0] = `"${s[0]}"`;
|
|
1117
1126
|
}
|
|
1118
1127
|
stream.write(`${date},"${parsha}",${s[0]},"${s[1]}",${s[2]}\r\n`);
|
|
1119
|
-
}
|
|
1128
|
+
}
|
|
1120
1129
|
stream.write('\r\n');
|
|
1121
1130
|
}
|
|
1122
1131
|
|
|
@@ -1128,8 +1137,7 @@ function writeCsvLines(stream, ev, reading, il, isParsha) {
|
|
|
1128
1137
|
function getFullKriyahLines(reading) {
|
|
1129
1138
|
const lines = [];
|
|
1130
1139
|
if (reading.fullkriyah) {
|
|
1131
|
-
Object.
|
|
1132
|
-
const a = reading.fullkriyah[num];
|
|
1140
|
+
for (const [num, a] of Object.entries(reading.fullkriyah)) {
|
|
1133
1141
|
if (typeof a !== 'undefined') {
|
|
1134
1142
|
var _reading$reason;
|
|
1135
1143
|
const k = num == 'M' ? 'maf' : num;
|
|
@@ -1139,7 +1147,7 @@ function getFullKriyahLines(reading) {
|
|
|
1139
1147
|
}
|
|
1140
1148
|
lines.push([k, aliyah, a.v || '']);
|
|
1141
1149
|
}
|
|
1142
|
-
}
|
|
1150
|
+
}
|
|
1143
1151
|
}
|
|
1144
1152
|
let specialHaftara = false;
|
|
1145
1153
|
if (reading.haftara) {
|
|
@@ -1160,13 +1168,12 @@ function getFullKriyahLines(reading) {
|
|
|
1160
1168
|
lines.push(['Alternate Haftara', haftara, reading.triHaftaraNumV || '']);
|
|
1161
1169
|
}
|
|
1162
1170
|
if (reading.megillah) {
|
|
1163
|
-
Object.
|
|
1164
|
-
const a = reading.megillah[num];
|
|
1171
|
+
for (const [num, a] of Object.entries(reading.megillah)) {
|
|
1165
1172
|
if (typeof a !== 'undefined') {
|
|
1166
1173
|
const aliyah = formatAliyahWithBook(a);
|
|
1167
1174
|
lines.push([`Megillah Ch. ${num}`, aliyah, a.v || '']);
|
|
1168
1175
|
}
|
|
1169
|
-
}
|
|
1176
|
+
}
|
|
1170
1177
|
}
|
|
1171
1178
|
return lines;
|
|
1172
1179
|
}
|
|
@@ -1188,6 +1195,7 @@ exports.getWeekdayReading = getWeekdayReading;
|
|
|
1188
1195
|
exports.hasFestival = hasFestival;
|
|
1189
1196
|
exports.lookupFestival = lookupFestival;
|
|
1190
1197
|
exports.lookupParsha = lookupParsha;
|
|
1198
|
+
exports.makeLeyningNames = makeLeyningNames;
|
|
1191
1199
|
exports.makeLeyningParts = makeLeyningParts;
|
|
1192
1200
|
exports.makeLeyningSummary = makeLeyningSummary;
|
|
1193
1201
|
exports.makeSummaryFromParts = makeSummaryFromParts;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/leyning v8.0
|
|
1
|
+
/*! @hebcal/leyning v8.1.0 */
|
|
2
2
|
import { flags, months, HDate, HebrewCalendar, Locale, ParshaEvent, Event } from '@hebcal/core';
|
|
3
3
|
|
|
4
4
|
const Genesis=[0,31,25,24,26,32,22,24,22,29,32,32,20,18,24,21,16,27,33,38,18,34,24,20,67,34,35,46,22,35,43,54,33,20,31,29,43,36,30,23,23,57,38,34,34,28,34,31,22,33,26];const Exodus=[0,22,25,22,31,23,30,29,28,35,29,10,51,22,31,27,36,16,27,25,26,37,30,33,18,40,37,21,43,46,38,18,35,23,35,35,38,29,31,43,38];const Leviticus=[0,17,16,17,35,26,23,38,36,24,20,47,8,59,57,33,34,16,30,37,27,24,33,44,23,55,46,34];const Numbers=[0,54,34,51,49,31,27,89,26,23,36,35,16,33,45,41,35,28,32,22,29,35,41,30,25,19,65,23,31,39,17,54,42,56,29,34,13];const Deuteronomy=[0,46,37,29,49,30,25,26,20,29,22,32,31,19,29,23,22,20,22,21,20,23,29,26,22,19,19,26,69,28,20,30,52,29,12];const Joshua=[0,18,24,17,24,15,27,26,35,27,43,23,24,33,15,63,10,18,28,51,9,45,34,16,33];const Judges=[0,36,23,31,24,31,40,25,35,57,18,40,15,25,20,20,31,13,31,30,48,25];const Ruth=[0,22,23,18,22];const Isaiah=[0,31,22,26,6,30,13,25,23,20,34,16,6,22,32,9,14,14,7,25,6,17,25,18,23,12,21,13,29,24,33,9,20,24,17,10,22,38,22,8,31,29,25,28,28,25,13,15,22,26,11,23,15,12,17,13,12,21,14,21,22,11,12,19,11,25,24];const Jeremiah=[0,19,37,25,31,31,30,34,23,25,25,23,17,27,22,21,21,27,23,15,18,14,30,40,10,38,24,22,17,32,24,40,44,26,22,19,32,21,28,18,16,18,22,13,30,5,28,7,47,39,46,64,34];const Lamentations=[0,22,22,66,22,22];const Baruch=[0,22,35,38,37,9,72];const Esther=[0,22,23,15,17,14,14,10,17,32,3];const Ecclesiastes=[0,18,26,22,17,19,12,29,17,18,20,10,14];const Ezekiel=[0,28,10,27,17,17,14,27,18,11,22,25,28,23,23,8,63,24,32,14,44,37,31,49,27,17,21,36,26,21,26,18,32,33,31,15,38,28,23,29,49,26,20,27,31,25,24,23,35];const Daniel=[0,21,49,100,34,30,29,28,27,27,21,45,13,64,42];const Hosea=[0,9,25,5,19,15,11,16,14,17,15,11,15,15,10];const Joel=[0,20,27,5,21];const Amos=[0,15,16,15,13,27,14,17,14,15];const Obadiah=[0,21];const Jonah=[0,16,11,10,11];const Micah=[0,16,13,12,14,14,16,20];const Nachum=[0,14,14,19];const Habakkuk=[0,17,20,19];const Zephaniah=[0,18,15,20];const Haggai=[0,15,23];const Zechariah=[0,17,17,10,14,11,15,14,23,17,12,17,14,9,21];const Malachi=[0,14,17,24];var numverses = {Genesis:Genesis,Exodus:Exodus,Leviticus:Leviticus,Numbers:Numbers,Deuteronomy:Deuteronomy,Joshua:Joshua,Judges:Judges,Ruth:Ruth,"I Samuel":[0,28,36,21,22,12,21,17,22,27,27,15,25,23,52,35,23,58,30,24,42,16,23,28,23,43,25,12,25,11,31,13],"II Samuel":[0,27,32,39,12,25,23,29,18,13,19,27,31,39,33,37,23,29,32,44,26,22,51,39,25],"I Kings":[0,53,46,28,20,32,38,51,66,28,29,43,33,34,31,34,34,24,46,21,43,29,54],"II Kings":[0,18,25,27,44,27,33,20,29,37,36,20,22,25,29,38,20,41,37,37,21,26,20,37,20,30],Isaiah:Isaiah,Jeremiah:Jeremiah,Lamentations:Lamentations,Baruch:Baruch,Esther:Esther,Ecclesiastes:Ecclesiastes,"Song of Songs":[0,17,17,11,16,16,12,14,14],Ezekiel:Ezekiel,Daniel:Daniel,Hosea:Hosea,Joel:Joel,Amos:Amos,Obadiah:Obadiah,Jonah:Jonah,Micah:Micah,Nachum:Nachum,Habakkuk:Habakkuk,Zephaniah:Zephaniah,Haggai:Haggai,Zechariah:Zechariah,Malachi:Malachi};
|
|
@@ -261,11 +261,11 @@ function lookupFestival(holiday) {
|
|
|
261
261
|
}
|
|
262
262
|
const result = src.fullkriyah ? clone(src) : src;
|
|
263
263
|
if (result.fullkriyah) {
|
|
264
|
-
Object.values(result.fullkriyah)
|
|
264
|
+
for (const aliyah of Object.values(result.fullkriyah)) {
|
|
265
265
|
if (typeof aliyah.k === 'number') {
|
|
266
266
|
aliyah.k = BOOK[aliyah.k];
|
|
267
267
|
}
|
|
268
|
-
}
|
|
268
|
+
}
|
|
269
269
|
}
|
|
270
270
|
if (src.note) {
|
|
271
271
|
result.note = src.note;
|
|
@@ -481,14 +481,16 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
481
481
|
if (special.fullkriyah) {
|
|
482
482
|
const aliyotMap = clone(aliyot);
|
|
483
483
|
mergeAliyotWithSpecial(aliyotMap, special.fullkriyah);
|
|
484
|
-
Object.keys(special.fullkriyah)
|
|
484
|
+
for (const num of Object.keys(special.fullkriyah)) {
|
|
485
|
+
reason[num] = key;
|
|
486
|
+
}
|
|
485
487
|
aliyot = aliyotMap;
|
|
486
488
|
}
|
|
487
489
|
}
|
|
488
490
|
const parshaName = parshaToString(parsha);
|
|
489
491
|
const events0 = HebrewCalendar.getHolidaysOnDate(hd, il) || [];
|
|
490
492
|
const events = events0.filter(ev => !(ev.getFlags() & flags.ROSH_CHODESH));
|
|
491
|
-
|
|
493
|
+
for (const ev of events) {
|
|
492
494
|
if (ev.getDesc() === 'Shabbat Shuva') {
|
|
493
495
|
handleSpecial(`Shabbat Shuva (with ${parshaName})`);
|
|
494
496
|
} else {
|
|
@@ -497,7 +499,7 @@ function specialReadings2(parsha, hd, il, aliyot) {
|
|
|
497
499
|
handleSpecial(key);
|
|
498
500
|
}
|
|
499
501
|
}
|
|
500
|
-
}
|
|
502
|
+
}
|
|
501
503
|
if (!haft) {
|
|
502
504
|
const day = hd.getDate();
|
|
503
505
|
if (parshaName === 'Pinchas' && day > 17) {
|
|
@@ -655,7 +657,7 @@ const Bereshit={num:1,hebrew:"בְּרֵאשִׁית",book:1,haft:{k:"Isaiah",b:
|
|
|
655
657
|
* @property {LeyningNames} name
|
|
656
658
|
* @property {string[]} [parsha] - An array of either 1 (regular) or 2 (doubled parsha).
|
|
657
659
|
* `undefined` for holiday readings
|
|
658
|
-
* @property {number} [parshaNum] - 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings
|
|
660
|
+
* @property {number|number[]} [parshaNum] - 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings
|
|
659
661
|
* @property {string} summary - Such as `Genesis 1:1 - 6:8`
|
|
660
662
|
* @property {Aliyah|Aliyah[]} haft - Haftarah object(s)
|
|
661
663
|
* @property {string} haftara - Haftarah, such as `Isaiah 42:5 – 43:11`
|
|
@@ -689,6 +691,19 @@ function getHaftaraKey(parsha) {
|
|
|
689
691
|
}
|
|
690
692
|
}
|
|
691
693
|
|
|
694
|
+
/**
|
|
695
|
+
* Transliterated English and Hebrew names of this parsha
|
|
696
|
+
* @param {string|string[]} parsha untranslated name like 'Pinchas' or ['Pinchas'] or ['Matot','Masei']
|
|
697
|
+
* @return {LeyningNames}
|
|
698
|
+
*/
|
|
699
|
+
function makeLeyningNames(parsha) {
|
|
700
|
+
const name = parshaToString(parsha);
|
|
701
|
+
return {
|
|
702
|
+
en: name,
|
|
703
|
+
he: parsha.map(s => Locale.lookupTranslation(s, 'he')).join('־')
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
|
|
692
707
|
/**
|
|
693
708
|
* Looks up regular leyning for a weekly parsha with no special readings
|
|
694
709
|
* @private
|
|
@@ -699,26 +714,22 @@ function getLeyningForParshaShabbatOnly(parsha) {
|
|
|
699
714
|
const raw = lookupParsha(parsha);
|
|
700
715
|
const fullkriyah = {};
|
|
701
716
|
const book = BOOK[raw.book];
|
|
702
|
-
Object.
|
|
703
|
-
const
|
|
704
|
-
const reading = {
|
|
717
|
+
for (const [num, src] of Object.entries(raw.fullkriyah)) {
|
|
718
|
+
const aliyah = {
|
|
705
719
|
k: book,
|
|
706
720
|
b: src[0],
|
|
707
721
|
e: src[1]
|
|
708
722
|
};
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
723
|
+
calculateNumVerses(aliyah);
|
|
724
|
+
fullkriyah[num] = aliyah;
|
|
725
|
+
}
|
|
712
726
|
const name = parshaToString(parsha);
|
|
713
727
|
const parshaNameArray = raw.combined ? [raw.p1, raw.p2] : [name];
|
|
714
728
|
const parts = makeLeyningParts(fullkriyah);
|
|
715
729
|
const summary = makeSummaryFromParts(parts);
|
|
716
730
|
/** @type {Leyning} */
|
|
717
731
|
const result = {
|
|
718
|
-
name:
|
|
719
|
-
en: name,
|
|
720
|
-
he: parshaNameArray.map(s => Locale.lookupTranslation(s, 'he')).join('־')
|
|
721
|
-
},
|
|
732
|
+
name: makeLeyningNames(parshaNameArray),
|
|
722
733
|
parsha: parshaNameArray,
|
|
723
734
|
parshaNum: raw.num,
|
|
724
735
|
summary,
|
|
@@ -820,18 +831,20 @@ function getLeyningForParshaHaShavua(ev, il = false) {
|
|
|
820
831
|
const reasons = Object.keys(reason);
|
|
821
832
|
if (reasons.length !== 0) {
|
|
822
833
|
result.reason = reason;
|
|
823
|
-
|
|
834
|
+
for (const num of reasons) {
|
|
824
835
|
if (num === 'haftara' || num === 'sephardic') {
|
|
825
836
|
const haftObj = result[num === 'haftara' ? 'haft' : 'seph'];
|
|
826
837
|
const hafts = Array.isArray(haftObj) ? haftObj : [haftObj];
|
|
827
|
-
|
|
838
|
+
for (const haft of hafts) {
|
|
839
|
+
haft.reason = reason[num];
|
|
840
|
+
}
|
|
828
841
|
} else {
|
|
829
842
|
const aliyah = result.fullkriyah[num];
|
|
830
843
|
if (typeof aliyah === 'object') {
|
|
831
844
|
aliyah.reason = reason[num];
|
|
832
845
|
}
|
|
833
846
|
}
|
|
834
|
-
}
|
|
847
|
+
}
|
|
835
848
|
}
|
|
836
849
|
return result;
|
|
837
850
|
}
|
|
@@ -922,48 +935,44 @@ function findParshaHaShavua(saturday, il) {
|
|
|
922
935
|
*/
|
|
923
936
|
function getLeyningOnDate(hdate, il, wantarray = false) {
|
|
924
937
|
const dow = hdate.getDay();
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
938
|
+
if (dow === 6) {
|
|
939
|
+
const hyear = hdate.getFullYear();
|
|
940
|
+
const sedra = HebrewCalendar.getSedra(hyear, il);
|
|
941
|
+
const parsha = sedra.lookup(hdate);
|
|
942
|
+
if (!parsha.chag) {
|
|
943
|
+
const parshaEvent = new ParshaEvent(hdate, parsha.parsha, il);
|
|
944
|
+
const reading = getLeyningForParshaHaShavua(parshaEvent, il);
|
|
945
|
+
return wantarray ? [reading] : reading;
|
|
946
|
+
}
|
|
932
947
|
}
|
|
933
948
|
const events = HebrewCalendar.getHolidaysOnDate(hdate, il) || [];
|
|
934
949
|
const arr = [];
|
|
935
|
-
|
|
936
|
-
|
|
950
|
+
let hasFullKriyah = false;
|
|
951
|
+
for (const ev of events) {
|
|
937
952
|
const reading = getLeyningForHoliday(ev, il);
|
|
938
953
|
if (reading) {
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
return reading;
|
|
954
|
+
arr.push(reading);
|
|
955
|
+
if (reading.fullkriyah) {
|
|
956
|
+
hasFullKriyah = true;
|
|
957
|
+
}
|
|
958
|
+
const mincha = getMincha(ev, il);
|
|
959
|
+
if (mincha) {
|
|
960
|
+
arr.push(mincha);
|
|
947
961
|
}
|
|
948
962
|
}
|
|
949
963
|
}
|
|
950
|
-
if (
|
|
951
|
-
return arr;
|
|
952
|
-
}
|
|
953
|
-
if (dow === 1 || dow === 4) {
|
|
964
|
+
if (!hasFullKriyah && (dow === 1 || dow === 4)) {
|
|
954
965
|
const saturday = hdate.onOrAfter(6);
|
|
955
|
-
const
|
|
956
|
-
const reading =
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
weekday: reading.weekday
|
|
966
|
+
const parsha = findParshaHaShavua(saturday);
|
|
967
|
+
const reading = {
|
|
968
|
+
name: makeLeyningNames(parsha.parsha),
|
|
969
|
+
parsha: parsha.parsha,
|
|
970
|
+
parshaNum: parsha.num,
|
|
971
|
+
weekday: getWeekdayReading(parsha.parsha)
|
|
962
972
|
};
|
|
963
|
-
|
|
973
|
+
arr.unshift(reading);
|
|
964
974
|
}
|
|
965
|
-
|
|
966
|
-
return wantarray ? [] : undefined;
|
|
975
|
+
return wantarray ? arr : arr[0];
|
|
967
976
|
}
|
|
968
977
|
const minchaSuffix = ' (Mincha)';
|
|
969
978
|
|
|
@@ -1035,11 +1044,11 @@ function writeFullKriyahCsv(stream, hyear, il) {
|
|
|
1035
1044
|
const events = events0.filter(ev => ev.getDesc() !== 'Rosh Chodesh Tevet');
|
|
1036
1045
|
const parshaDates = getParshaDates(events);
|
|
1037
1046
|
stream.write('"Date","Parashah","Aliyah","Reading","Verses"\r\n');
|
|
1038
|
-
|
|
1047
|
+
for (const ev of events) {
|
|
1039
1048
|
if (ev.getFlags() === flags.PARSHA_HASHAVUA || !parshaDates[ev.getDate().toString()]) {
|
|
1040
1049
|
writeFullKriyahEvent(stream, ev, il);
|
|
1041
1050
|
}
|
|
1042
|
-
}
|
|
1051
|
+
}
|
|
1043
1052
|
}
|
|
1044
1053
|
|
|
1045
1054
|
/**
|
|
@@ -1108,13 +1117,13 @@ function writeCsvLines(stream, ev, reading, il, isParsha) {
|
|
|
1108
1117
|
const parsha = isParsha ? ev.basename() : getLeyningKeyForEvent(ev, il) || ev.render();
|
|
1109
1118
|
const date = fmtDate(ev.getDate().greg());
|
|
1110
1119
|
const lines = getFullKriyahLines(reading);
|
|
1111
|
-
|
|
1120
|
+
for (const s of lines) {
|
|
1112
1121
|
const code = s[0].charCodeAt(0);
|
|
1113
1122
|
if (code < 48 || code > 57) {
|
|
1114
1123
|
s[0] = `"${s[0]}"`;
|
|
1115
1124
|
}
|
|
1116
1125
|
stream.write(`${date},"${parsha}",${s[0]},"${s[1]}",${s[2]}\r\n`);
|
|
1117
|
-
}
|
|
1126
|
+
}
|
|
1118
1127
|
stream.write('\r\n');
|
|
1119
1128
|
}
|
|
1120
1129
|
|
|
@@ -1126,8 +1135,7 @@ function writeCsvLines(stream, ev, reading, il, isParsha) {
|
|
|
1126
1135
|
function getFullKriyahLines(reading) {
|
|
1127
1136
|
const lines = [];
|
|
1128
1137
|
if (reading.fullkriyah) {
|
|
1129
|
-
Object.
|
|
1130
|
-
const a = reading.fullkriyah[num];
|
|
1138
|
+
for (const [num, a] of Object.entries(reading.fullkriyah)) {
|
|
1131
1139
|
if (typeof a !== 'undefined') {
|
|
1132
1140
|
var _reading$reason;
|
|
1133
1141
|
const k = num == 'M' ? 'maf' : num;
|
|
@@ -1137,7 +1145,7 @@ function getFullKriyahLines(reading) {
|
|
|
1137
1145
|
}
|
|
1138
1146
|
lines.push([k, aliyah, a.v || '']);
|
|
1139
1147
|
}
|
|
1140
|
-
}
|
|
1148
|
+
}
|
|
1141
1149
|
}
|
|
1142
1150
|
let specialHaftara = false;
|
|
1143
1151
|
if (reading.haftara) {
|
|
@@ -1158,15 +1166,14 @@ function getFullKriyahLines(reading) {
|
|
|
1158
1166
|
lines.push(['Alternate Haftara', haftara, reading.triHaftaraNumV || '']);
|
|
1159
1167
|
}
|
|
1160
1168
|
if (reading.megillah) {
|
|
1161
|
-
Object.
|
|
1162
|
-
const a = reading.megillah[num];
|
|
1169
|
+
for (const [num, a] of Object.entries(reading.megillah)) {
|
|
1163
1170
|
if (typeof a !== 'undefined') {
|
|
1164
1171
|
const aliyah = formatAliyahWithBook(a);
|
|
1165
1172
|
lines.push([`Megillah Ch. ${num}`, aliyah, a.v || '']);
|
|
1166
1173
|
}
|
|
1167
|
-
}
|
|
1174
|
+
}
|
|
1168
1175
|
}
|
|
1169
1176
|
return lines;
|
|
1170
1177
|
}
|
|
1171
1178
|
|
|
1172
|
-
export { BOOK, calculateNumVerses, clone, cloneHaftara, formatAliyahShort, formatAliyahWithBook, getLeyningForHoliday, getLeyningForHolidayKey, getLeyningForParsha, getLeyningForParshaHaShavua, getLeyningKeyForEvent, getLeyningOnDate, getParshaDates, getWeekdayReading, hasFestival, lookupFestival, lookupParsha, makeLeyningParts, makeLeyningSummary, makeSummaryFromParts, parshaToString, specialReadings2, sumVerses, writeCsvLines, writeFullKriyahCsv, writeHolidayMincha };
|
|
1179
|
+
export { BOOK, calculateNumVerses, clone, cloneHaftara, formatAliyahShort, formatAliyahWithBook, getLeyningForHoliday, getLeyningForHolidayKey, getLeyningForParsha, getLeyningForParshaHaShavua, getLeyningKeyForEvent, getLeyningOnDate, getParshaDates, getWeekdayReading, hasFestival, lookupFestival, lookupParsha, makeLeyningNames, makeLeyningParts, makeLeyningSummary, makeSummaryFromParts, parshaToString, specialReadings2, sumVerses, writeCsvLines, writeFullKriyahCsv, writeHolidayMincha };
|
package/leyning.d.ts
CHANGED
|
@@ -28,17 +28,26 @@ declare module '@hebcal/leyning' {
|
|
|
28
28
|
[key: string]: Aliyah;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/** Name of the parsha hashavua or holiday */
|
|
32
|
+
export type LeyningNames = {
|
|
33
|
+
/** English */
|
|
34
|
+
en: string;
|
|
35
|
+
/** Hebrew (with nikud) */
|
|
36
|
+
he: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Transliterated English and Hebrew names of this parsha
|
|
41
|
+
* @param parsha untranslated name like 'Pinchas' or ['Pinchas'] or ['Matot','Masei']
|
|
42
|
+
*/
|
|
43
|
+
export function makeLeyningNames(parsha: string | string[]): LeyningNames;
|
|
44
|
+
|
|
31
45
|
/**
|
|
32
46
|
* Leyning for a parsha hashavua or holiday
|
|
33
47
|
*/
|
|
34
48
|
export type Leyning = {
|
|
35
49
|
/** Name of the parsha hashavua or holiday */
|
|
36
|
-
name:
|
|
37
|
-
/** English */
|
|
38
|
-
en: string;
|
|
39
|
-
/** Hebrew (with nikud) */
|
|
40
|
-
he: string;
|
|
41
|
-
};
|
|
50
|
+
name: LeyningNames;
|
|
42
51
|
/** An array of either 1 (regular) or 2 (doubled parsha). `undefined` for holiday readings */
|
|
43
52
|
parsha?: string[];
|
|
44
53
|
/** 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hebcal/leyning",
|
|
3
|
-
"version": "8.0
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"author": "Michael J. Radwin (https://github.com/mjradwin)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hebcal",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"leyning-csv": "bin/leyning-csv"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@hebcal/core": "^5.0.
|
|
34
|
+
"@hebcal/core": "^5.0.1"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "rollup -c",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
"eslint-config-google": "^0.14.0",
|
|
62
62
|
"jsdoc": "^4.0.2",
|
|
63
63
|
"jsdoc-to-markdown": "^8.0.0",
|
|
64
|
-
"rollup": "^4.
|
|
64
|
+
"rollup": "^4.7.0"
|
|
65
65
|
}
|
|
66
66
|
}
|