Skip to content

Commit

Permalink
Fix Mon/Thu weekday reading that coincides with Erev.
Browse files Browse the repository at this point in the history
Now that we are really targeting modern ES6 syntax, more freely use iterators, replacing some use of Array.forEach()
  • Loading branch information
mjradwin committed Dec 10, 2023
1 parent 17c3188 commit c57bdfb
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 138 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ of full kriyah aliyot, special Maftir, special Haftarah</p>
<dd><p>Looks up leyning for a given holiday. Returns some
of full kriyah aliyot, special Maftir, special Haftarah</p>
</dd>
<dt><a href="#makeLeyningNames">makeLeyningNames(parsha)</a> ⇒ <code><a href="#LeyningNames">LeyningNames</a></code></dt>
<dd><p>Transliterated English and Hebrew names of this parsha</p>
</dd>
<dt><a href="#getWeekdayReading">getWeekdayReading(parsha)</a> ⇒ <code>Object.&lt;string, Aliyah&gt;</code></dt>
<dd><p>Looks up Monday/Thursday aliyot for a regular parsha</p>
</dd>
Expand Down Expand Up @@ -357,6 +360,17 @@ of full kriyah aliyot, special Maftir, special Haftarah
| ev | <code>Event</code> | | the Hebcal event associated with this leyning |
| [il] | <code>boolean</code> | <code>false</code> | true if Israel holiday scheme |

<a name="makeLeyningNames"></a>

## makeLeyningNames(parsha) ⇒ [<code>LeyningNames</code>](#LeyningNames)
Transliterated English and Hebrew names of this parsha

**Kind**: global function

| Param | Type | Description |
| --- | --- | --- |
| parsha | <code>string</code> \| <code>Array.&lt;string&gt;</code> | untranslated name like 'Pinchas' or ['Pinchas'] or ['Matot','Masei'] |

<a name="getWeekdayReading"></a>

## getWeekdayReading(parsha) ⇒ <code>Object.&lt;string, Aliyah&gt;</code>
Expand Down Expand Up @@ -501,7 +515,7 @@ Leyning for a parsha hashavua or holiday
| --- | --- | --- |
| name | [<code>LeyningNames</code>](#LeyningNames) | |
| [parsha] | <code>Array.&lt;string&gt;</code> | An array of either 1 (regular) or 2 (doubled parsha). `undefined` for holiday readings |
| [parshaNum] | <code>number</code> | 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings |
| [parshaNum] | <code>number</code> \| <code>Array.&lt;number&gt;</code> | 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings |
| summary | <code>string</code> | Such as `Genesis 1:1 - 6:8` |
| haft | [<code>Aliyah</code>](#Aliyah) \| [<code>Array.&lt;Aliyah&gt;</code>](#Aliyah) | Haftarah object(s) |
| haftara | <code>string</code> | Haftarah, such as `Isaiah 42:5 – 43:11` |
Expand Down
21 changes: 15 additions & 6 deletions leyning.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,26 @@ declare module '@hebcal/leyning' {
[key: string]: Aliyah;
}

/** Name of the parsha hashavua or holiday */
export type LeyningNames = {
/** English */
en: string;
/** Hebrew (with nikud) */
he: string;
}

/**
* Transliterated English and Hebrew names of this parsha
* @param parsha untranslated name like 'Pinchas' or ['Pinchas'] or ['Matot','Masei']
*/
export function makeLeyningNames(parsha: string | string[]): LeyningNames;

/**
* Leyning for a parsha hashavua or holiday
*/
export type Leyning = {
/** Name of the parsha hashavua or holiday */
name: {
/** English */
en: string;
/** Hebrew (with nikud) */
he: string;
};
name: LeyningNames;
/** An array of either 1 (regular) or 2 (doubled parsha). `undefined` for holiday readings */
parsha?: string[];
/** 1 for Bereshit, 2 for Noach, etc. `undefined` for holiday readings */
Expand Down
142 changes: 78 additions & 64 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/leyning",
"version": "8.0.1",
"version": "8.1.0",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"keywords": [
"hebcal",
Expand Down Expand Up @@ -31,7 +31,7 @@
"leyning-csv": "bin/leyning-csv"
},
"dependencies": {
"@hebcal/core": "^5.0.0"
"@hebcal/core": "^5.0.1"
},
"scripts": {
"build": "rollup -c",
Expand Down Expand Up @@ -61,6 +61,6 @@
"eslint-config-google": "^0.14.0",
"jsdoc": "^4.0.2",
"jsdoc-to-markdown": "^8.0.0",
"rollup": "^4.6.1"
"rollup": "^4.7.0"
}
}
4 changes: 2 additions & 2 deletions src/calculateHaftarahNumVerses.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function calculateHaftarahNumVerses(haftara) {
const sections = haftara.split(/[;,]/);
let total = 0;
let prevBook;
sections.forEach((haft) => {
for (const haft of sections) {
const matches = haft.trim().match(/^(([^\d]+)\s+)?(\d.+)$/);
if (matches !== null) {
const hbook = matches[2] ? matches[2].trim() : prevBook;
Expand All @@ -27,6 +27,6 @@ export function calculateHaftarahNumVerses(haftara) {
}
prevBook = hbook;
}
});
}
return total || undefined;
}
Loading

0 comments on commit c57bdfb

Please sign in to comment.