quran-meta
Version:
Library with meta data and functionality related to Holy Quran
28 lines (26 loc) • 882 B
JavaScript
import { checkValidJuz } from "./validation.mjs";
import { findSurahAyahByAyahId } from "./findSurahAyahByAyahId.mjs";
//#region src/getJuzMeta.ts
/**
* Retrieves metadata for a specific Juz of the Quran.
*
* @param juzNum - The Juz number to retrieve metadata for (1-30)
* @param data - The Lists object for the riwaya.
* @returns An object containing the Juz number, first ayah, and last ayah in the Juz
* @throws RangeError If the Juz number is not between 1 and 30
*/
function getJuzMeta(juzNum, data) {
checkValidJuz(juzNum, data.meta);
const JuzList = data.JuzList;
const [firstAyahId, nextJuzAyahId] = [JuzList[juzNum], JuzList[juzNum + 1]];
const lastAyahId = nextJuzAyahId - 1;
return {
juzNum,
firstAyahId,
lastAyahId,
first: findSurahAyahByAyahId(firstAyahId, data),
last: findSurahAyahByAyahId(lastAyahId, data)
};
}
//#endregion
export { getJuzMeta };