quran-meta
Version:
Library with meta data and functionality related to Holy Quran
43 lines (30 loc) • 1.24 kB
JavaScript
const require_validation = require('./validation.cjs');
const require_findSurahAyahByAyahId = require('./findSurahAyahByAyahId.cjs');
const require_manzilList = require('./lists/manzilList.cjs');
//#region src/getManzilMeta.ts
/**
* Retrieves metadata for a specific Manzil (section) of the Quran
*
* @param manzilNum - The number of the Manzil (1-7)
* @returns The metadata for the specified Manzil containing:
* - manzilNum: The Manzil number
* - firstAyahId: ID of the first ayah in the Manzil
* - lastAyahId: ID of the last ayah in the Manzil
* - first: Surah and ayah details of the first ayah
* - last: Surah and ayah details of the last ayah
* @throws Will throw an error if manzilNum is invalid
*/
function getManzilMeta(manzilNum) {
require_validation.checkValidManzil(manzilNum);
const [firstAyahId, nextManzilAyahId] = [require_manzilList.ManzilList[manzilNum], require_manzilList.ManzilList[manzilNum + 1]];
const lastAyahId = nextManzilAyahId - 1;
return {
manzilNum,
firstAyahId,
lastAyahId,
first: require_findSurahAyahByAyahId.findSurahAyahByAyahId(firstAyahId),
last: require_findSurahAyahByAyahId.findSurahAyahByAyahId(lastAyahId)
};
}
//#endregion
exports.getManzilMeta = getManzilMeta;