@hebcal/leyning
Version:
Torah Reading API for Parashat HaShavua and holidays
49 lines (46 loc) • 1.27 kB
JavaScript
/*! @hebcal/leyning v9.5.4 */
import { BOOK } from './common.js';
import festivals0 from './holiday-readings.json.js';
const festivals = festivals0;
/**
* Is there a special festival Torah Reading for `holiday`?
*/
function hasFestival(holiday) {
return typeof festivals[holiday] === 'object';
}
function aliyotBookNumToStr(aliyot) {
if (aliyot) {
for (const aliyah of Object.values(aliyot)) {
if (typeof aliyah.k === 'number') {
aliyah.k = BOOK[aliyah.k];
}
}
}
}
/**
* Returns the raw metadata for festival reading for `holiday`
*/
function lookupFestival(holiday) {
let src = festivals[holiday];
if (!src) {
return undefined;
}
if (src.alias) {
const tmp = festivals[src.key];
if (!tmp) {
throw new Error(`Leyning alias ${holiday} => ${src.key} not found`);
}
src = tmp;
}
const result = src.fullkriyah
? structuredClone(src)
: src;
aliyotBookNumToStr(result.fullkriyah);
aliyotBookNumToStr(result.alt);
if (src.chabad && 'sameas' in src.chabad) {
result.chabad = result.haft;
}
return result;
}
export { hasFestival, lookupFestival };
//# sourceMappingURL=festival.js.map