quran-meta
Version:
Library with meta data and functionality related to Holy Quran
33 lines (25 loc) • 823 B
JavaScript
import { checkValidJuz } from "./validation.js";
import { JuzList } from "./lists/juzList.js";
import { findSurahAyahByAyahId } from "./findSurahAyahByAyahId.js";
//#region src/getJuzMeta.ts
/**
* Retrieves metadata for a specific Juz of the Quran.
*
* @param juzNum - The Juz number to retrieve metadata for (1-30)
* @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) {
checkValidJuz(juzNum);
const [firstAyahId, nextJuzAyahId] = [JuzList[juzNum], JuzList[juzNum + 1]];
const lastAyahId = nextJuzAyahId - 1;
return {
juzNum,
firstAyahId,
lastAyahId,
first: findSurahAyahByAyahId(firstAyahId),
last: findSurahAyahByAyahId(lastAyahId)
};
}
//#endregion
export { getJuzMeta };