hebcal-leyning
Javascript Torah Reading API for Parashat HaShavua and holidays
Installation
$ npm install @hebcal/leyning
Synopsis
import {HebrewCalendar, HDate, Event} from '@hebcal/core';
import leyning from '@hebcal/leyning';
const options = {sedrot: true, noHolidays: true};
const events = HebrewCalendar.calendar(options);
const ev = events.find((ev) => ev.getDesc() == 'Parashat Pinchas');
const reading = leyning.getLeyningForParshaHaShavua(ev);
console.log(`${ev.getDesc()}: ${reading.summary}`);
console.log(`Haftara: ${reading.haftara}`);
for (const [num, aliyah] of Object.entries(reading.fullkriyah)) {
const number = num == 'M' ? 'maftir' : `aliyah ${num}`;
let str = leyning.formatAliyahWithBook(aliyah);
if (reading.reason[num]) {
str += ' | ' + reading.reason[num];
}
console.log(`${number}: ${str}`);
}
const triReading = triennial.getTriennialForParshaHaShavua(ev);
for (const [num, aliyah] of Object.entries(triReading)) {
const number = num == 'M' ? 'maftir' : `aliyah ${num}`;
const str = leyning.formatAliyahWithBook(aliyah);
console.log(`Triennial ${number}: ${str}`);
}
Classes
- Triennial
-
Triennial Torah readings
Constants
- leyning
-
Main interface to hebcal/leyning
Functions
- addSefariaLinksToLeyning(aliyot, showBook)
-
Makes Sefaria links by adding
href
,verses
andnum
attributes to each aliyah. CAUTION: Modifies thealiyot
parameter instead of making a copy. -
getLeyningKeyForEvent(e, [il]) ⇒
string
-
Based on the event date, type and title, finds the relevant leyning key
-
getLeyningForHoliday(e, [il]) ⇒
Leyning
-
Looks up leyning for a given holiday. Returns some of full kriyah aliyot, special Maftir, special Haftarah
-
getLeyningForHolidayKey(key) ⇒
Leyning
-
Looks up leyning for a given holiday key. Key should be an (untranslated) string used in holiday-readings.json. Returns some of full kriyah aliyot, special Maftir, special Haftarah
-
parshaToString(parsha) ⇒
string
-
Formats parsha as a string
-
getHaftaraKey(parsha) ⇒
string
-
on doubled parshiot, read only the second Haftarah except for Nitzavim-Vayelech
-
getChanukahShabbatKey(e, key) ⇒
string
-
getHolidayEvents(hd, il) ⇒
Array.<Event>
-
Filters out Rosh Chodesh and events that don't occur in this location
-
getLeyningForParshaHaShavua(e, [il]) ⇒
Leyning
-
Looks up leyning for a regular Shabbat parsha.
-
formatAliyahWithBook(a) ⇒
string
-
Formats an aliyah object like "Numbers 28:9 - 28:15"
-
getDoubledName(id) ⇒
string
-
takes a 0-based (Bereshit=0) parsha ID
-
getTriennial(year) ⇒
Triennial
-
Calculates the 3-year readings for a given year
-
getTriennialForParshaHaShavua(ev, [context]) ⇒
TriennialAliyot
|Object.<string, Aliyah>
-
Looks up the triennial leyning for this Parashat HaShavua
Typedefs
-
Aliyah :
Object
-
Represents an aliyah
-
Leyning :
Object
-
Leyning for a parsha hashavua or holiday
-
TriennialAliyot :
Object
-
Represents triennial aliyot for a given date
Triennial
Triennial Torah readings
Kind: global class
-
Triennial
- new Triennial([hebrewYear])
-
instance
-
.getReading(parsha, yearNum) ⇒
Object.<string, Aliyah>
-
.getStartYear() ⇒
number
-
.getThreeYearPattern(id) ⇒
string
-
.cycleReadings(cycleOption) ⇒
Map.<string, Array.<Object>>
- .cycleReadingsForYear(option, readings, yr)
-
.getReading(parsha, yearNum) ⇒
-
static
-
.getYearNumber(year) ⇒
number
-
.getCycleStartYear(year) ⇒
number
-
.getTriennialAliyot() ⇒
Object
-
.resolveSameAs(parsha, book, triennial) ⇒
Object
-
.getYearNumber(year) ⇒
new Triennial([hebrewYear])
Builds a Triennial object
Param | Type | Description |
---|---|---|
[hebrewYear] | number |
Hebrew Year (default current year) |
Object.<string, Aliyah>
triennial.getReading(parsha, yearNum) ⇒ Kind: instance method of Triennial
Returns: Object.<string, Aliyah>
- a map of aliyot 1-7 plus "M"
Param | Type | Description |
---|---|---|
parsha | string |
parsha name ("Bereshit" or "Achrei Mot-Kedoshim") |
yearNum | number |
0 through 2 for which year of Triennial cycle |
number
triennial.getStartYear() ⇒ Kind: instance method of Triennial
string
triennial.getThreeYearPattern(id) ⇒ First, determine if a doubled parsha is read [T]ogether or [S]eparately in each of the 3 years. Yields a pattern like 'SSS', 'STS', 'TTT', 'TTS'.
Kind: instance method of Triennial
Param | Type |
---|---|
id | number |
Map.<string, Array.<Object>>
triennial.cycleReadings(cycleOption) ⇒ Builds a lookup table readings["Bereshit"][0], readings["Matot-Masei"][2]
Kind: instance method of Triennial
Param | Type |
---|---|
cycleOption | Object |
triennial.cycleReadingsForYear(option, readings, yr)
Kind: instance method of Triennial
Param | Type |
---|---|
option | string |
readings | Map.<string, Array.<Object>> |
yr | number |
number
Triennial.getYearNumber(year) ⇒ Returns triennial year 1, 2 or 3 based on this Hebrew year
Kind: static method of Triennial
Param | Type | Description |
---|---|---|
year | number |
Hebrew year |
number
Triennial.getCycleStartYear(year) ⇒ Returns Hebrew year that this 3-year triennial cycle began
Kind: static method of Triennial
Param | Type | Description |
---|---|---|
year | number |
Hebrew year |
Object
Triennial.getTriennialAliyot() ⇒ Walks parshiyotObj and builds lookup table for triennial aliyot
Kind: static method of Triennial
Object
Triennial.resolveSameAs(parsha, book, triennial) ⇒ Transforms input JSON with sameAs shortcuts like "D.2":"A.3" to actual aliyot objects for a given variation/year
Kind: static method of Triennial
Param | Type |
---|---|
parsha | string |
book | string |
triennial | Object |
leyning
Main interface to hebcal/leyning
addSefariaLinksToLeyning(aliyot, showBook)
Makes Sefaria links by adding href
, verses
and num
attributes to each aliyah.
CAUTION: Modifies the aliyot
parameter instead of making a copy.
Kind: global function
Param | Type | Description |
---|---|---|
aliyot | Object.<string, Aliyah> |
aliyah map to decorate |
showBook | boolean |
display the book name in the verses field (e.g. for special Maftir) |
string
getLeyningKeyForEvent(e, [il]) ⇒ Based on the event date, type and title, finds the relevant leyning key
Kind: global function
Returns: string
- key to look up in holiday-reading.json
Param | Type | Default | Description |
---|---|---|---|
e | Event |
event | |
[il] | boolean |
false |
true if Israel holiday scheme |
Leyning
getLeyningForHoliday(e, [il]) ⇒ Looks up leyning for a given holiday. Returns some of full kriyah aliyot, special Maftir, special Haftarah
Kind: global function
Returns: Leyning
- map of aliyot
Param | Type | Default | Description |
---|---|---|---|
e | Event |
the Hebcal event associated with this leyning | |
[il] | boolean |
false |
true if Israel holiday scheme |
Leyning
getLeyningForHolidayKey(key) ⇒ Looks up leyning for a given holiday key. Key should be an (untranslated) string used in holiday-readings.json. Returns some of full kriyah aliyot, special Maftir, special Haftarah
Kind: global function
Returns: Leyning
- map of aliyot
Param | Type | Description |
---|---|---|
key | string |
name from holiday-readings.json to find |
string
parshaToString(parsha) ⇒ Formats parsha as a string
Kind: global function
Param | Type |
---|---|
parsha | Array.<string> |
string
getHaftaraKey(parsha) ⇒ on doubled parshiot, read only the second Haftarah except for Nitzavim-Vayelech
Kind: global function
Param | Type |
---|---|
parsha | Array.<string> |
string
getChanukahShabbatKey(e, key) ⇒ Kind: global function
Param | Type |
---|---|
e | Event |
key | string |
Array.<Event>
getHolidayEvents(hd, il) ⇒ Filters out Rosh Chodesh and events that don't occur in this location
Kind: global function
Param | Type | Description |
---|---|---|
hd | HDate |
Hebrew date |
il | boolean |
in Israel |
Leyning
getLeyningForParshaHaShavua(e, [il]) ⇒ Looks up leyning for a regular Shabbat parsha.
Kind: global function
Returns: Leyning
- map of aliyot
Param | Type | Default | Description |
---|---|---|---|
e | Event |
the Hebcal event associated with this leyning | |
[il] | boolean |
false |
in Israel |
string
formatAliyahWithBook(a) ⇒ Formats an aliyah object like "Numbers 28:9 - 28:15"
Kind: global function
Param | Type | Description |
---|---|---|
a | Aliyah |
aliyah |
string
getDoubledName(id) ⇒ takes a 0-based (Bereshit=0) parsha ID
Kind: global function
Param | Type |
---|---|
id | number |
Triennial
getTriennial(year) ⇒ Calculates the 3-year readings for a given year
Kind: global function
Param | Type | Description |
---|---|---|
year | number |
Hebrew year |
TriennialAliyot
| Object.<string, Aliyah>
getTriennialForParshaHaShavua(ev, [context]) ⇒ Looks up the triennial leyning for this Parashat HaShavua
Kind: global function
Returns: TriennialAliyot
| Object.<string, Aliyah>
- a map of aliyot 1-7 plus "M"
Param | Type | Default | Description |
---|---|---|---|
ev | Event |
||
[context] | boolean |
false |
returns a reading wrapper object which includes date , yearNum and aliyot
|
Object
Aliyah : Represents an aliyah
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
k | string |
Book (e.g. "Numbers") |
b | string |
beginning verse (e.g. "28:9") |
e | string |
ending verse (e.g. "28:15") |
[v] | number |
number of verses |
[p] | number |
parsha number (1=Bereshit, 54=Vezot HaBracha) |
Object
Leyning : Leyning for a parsha hashavua or holiday
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
summary | string |
|
haftara | string |
Haftarah |
sephardic | string |
Haftarah for Sephardic |
fullkriyah | Object.<string, Aliyah> |
|
[reason] | Object |
Object
TriennialAliyot : Represents triennial aliyot for a given date
Kind: global typedef
Properties
Name | Type | Description |
---|---|---|
aliyot | Object.<string, Aliyah> |
a map of aliyot 1-7 plus "M" |
yearNum | number |
year number, 0-2 |
date | Date |
Shabbat date for when this parsha is read in this 3-year cycle |
[readSeparately] | boolean |
true if a double parsha is read separately in year yearNum
|
[date1] | Date |
Shabbat date of the first part of a read-separately aliyah pair |
[date2] | Date |
Shabbat date of the second part of a read-separately aliyah pair |