UNPKG

quran-meta

Version:

Library with meta data and functionality related to Holy Quran

31 lines (29 loc) 941 B
import { HafsLists, HafsMeta } from "./HafsLists.mjs"; import { QalunLists, QalunMeta } from "./QalunLists.mjs"; import { WarshLists, WarshMeta } from "./WarshLists.mjs"; //#region src/lists/index.ts /** * Retrieves the lists associated with a specific Riwaya. * Uses switch statement to enable tree-shaking. * * @example * ```typescript * const hafsLists = getListsOfRiwaya('Hafs'); * ``` */ function getListsOfRiwaya(riwaya) { switch (riwaya) { case "Hafs": return HafsLists; case "Qalun": return QalunLists; case "Warsh": return WarshLists; default: throw new Error(`Unknown riwaya: ${riwaya}`); } } const getListOfRiwaya = (listName, riwaya) => { const actualRiwaya = riwaya || "Hafs"; const lists = getListsOfRiwaya(actualRiwaya); if (listName in lists) return lists[listName]; throw new Error(`List ${String(listName)} not found in ${actualRiwaya} riwaya`); }; //#endregion export { getListOfRiwaya, getListsOfRiwaya };