quran-meta
Version:
Library with meta data and functionality related to Holy Quran
28 lines (26 loc) • 1.02 kB
JavaScript
const require_validation = require('./validation.cjs');
const require_findSurahAyahByAyahId = require('./findSurahAyahByAyahId.cjs');
//#region src/getPageMeta.ts
/**
* Retrieves metadata for a specific page of the Quran.
*
* @param pageNum - The page number to retrieve metadata for (1-604)
* @param data - The Lists object for the riwaya.
* @returns {@link PageMeta} An object containing the page number, first ayah, and last ayah on the page
* @throws {@link RangeError} If the page number is not between 1 and 604
*/
function getPageMeta(pageNum, data) {
require_validation.checkValidPage(pageNum, data.meta);
const PageList = data.PageList;
const [firstAyahId, nextPage] = [PageList[pageNum], PageList[pageNum + 1]];
const lastAyahId = nextPage - 1;
return {
pageNum,
firstAyahId,
lastAyahId,
first: require_findSurahAyahByAyahId.findSurahAyahByAyahId(firstAyahId, data),
last: require_findSurahAyahByAyahId.findSurahAyahByAyahId(lastAyahId, data)
};
}
//#endregion
exports.getPageMeta = getPageMeta;