Skip to content

Commit

Permalink
Shrink holiday JSON by using numerical 1-5 for Genesis-Deuteronomy
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Jul 7, 2022
1 parent 59c9d90 commit 1dfb957
Show file tree
Hide file tree
Showing 3 changed files with 353 additions and 321 deletions.
39 changes: 39 additions & 0 deletions src/festival.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import festivals from './holiday-readings.json';
import {BOOK, clone} from './common';

/**
* @private
* @param {string} key
* @return {boolean}
*/
export function hasFestival(key) {
return typeof festivals[key] === 'object';
}

/**
* @private
* @param {string} key
* @return {any}
*/
export function lookupFestival(key) {
let src = festivals[key];
if (typeof src === 'undefined') {
return undefined;
}
if (src.alias) {
const tmp = festivals[src.key];
if (typeof tmp === 'undefined') {
throw new Error(`Leying key ${key} => ${src.key} not found`);
}
src = tmp;
}
const result = src.fullkriyah ? clone(src) : src;
if (result.fullkriyah) {
Object.values(result.fullkriyah).forEach((aliyah) => {
if (typeof aliyah.k === 'number') {
aliyah.k = BOOK[aliyah.k];
}
});
}
return result;
}
Loading

0 comments on commit 1dfb957

Please sign in to comment.