UNPKG

quran-meta

Version:

Library with meta data and functionality related to Holy Quran

27 lines (25 loc) 1 kB
const require_validation = require('./validation.cjs'); const require_findSurahAyahByAyahId = require('./findSurahAyahByAyahId.cjs'); const require_pageList = require('./lists/pageList.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) * @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) { require_validation.checkValidPage(pageNum); const [firstAyahId, nextPage] = [require_pageList.PageList[pageNum], require_pageList.PageList[pageNum + 1]]; const lastAyahId = nextPage - 1; return { pageNum, firstAyahId, lastAyahId, first: require_findSurahAyahByAyahId.findSurahAyahByAyahId(firstAyahId), last: require_findSurahAyahByAyahId.findSurahAyahByAyahId(lastAyahId) }; } //#endregion exports.getPageMeta = getPageMeta;